A symbolic package using SymPy

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

A symbolic package using SymPy

Colin Macdonald
Hi,

I've been tinkering with making a symbolic package using the Python
CAS SymPy.  The goal is feature parity with other symbolic packages.

You can try it now, either git clone, or just download a .zip file
(which works as a GNU Octave package).

https://github.com/cbm755/octsympy

Here's some examples:

 > pkg install octsympy-master.zip
 > pkg load octsympy
 > syms x y z a b c k
 > A = [sin(x/2) floor(exp(x*c)); ...
acosh(x^(b*c)/pi) ceil(sin(x/gamma(x)))]
 > pretty(A)
 >
 > f = exp(-x^2);
 > F = fourier(f,x,k);
 > pretty(F)
 > g = ifourier(F,k,x);
 > simplify(f - g)
 >
 > limit(1/x, x, 0, 'left')

If you have problems with the Python communication (I've only tested
on GNU/Linux and my guess is it doesn't work out-of-box on Windows), try:

 > octsympy_config ipc_system

I'd be happy to move everything elsewhere at some point, but for now,
issue tracker is also at GitHub, so please give it a try and file some
bugs ;-)  Help also very much appreciated!

best,
Colin

--
Colin Macdonald
University Lecturer in Numerical Methodologies
Tutorial Fellow at Oriel College
University of Oxford

Reply | Threaded
Open this post in threaded view
|

Re: A symbolic package using SymPy

Juan Pablo Carbajal-2
On Thu, Apr 17, 2014 at 3:34 PM, Colin Macdonald
<[hidden email]> wrote:

> Hi,
>
> I've been tinkering with making a symbolic package using the Python CAS
> SymPy.  The goal is feature parity with other symbolic packages.
>
> You can try it now, either git clone, or just download a .zip file (which
> works as a GNU Octave package).
>
> https://github.com/cbm755/octsympy
>
> Here's some examples:
>
>> pkg install octsympy-master.zip
>> pkg load octsympy
>> syms x y z a b c k
>> A = [sin(x/2) floor(exp(x*c)); ...
> acosh(x^(b*c)/pi) ceil(sin(x/gamma(x)))]
>> pretty(A)
>>
>> f = exp(-x^2);
>> F = fourier(f,x,k);
>> pretty(F)
>> g = ifourier(F,k,x);
>> simplify(f - g)
>>
>> limit(1/x, x, 0, 'left')
>
> If you have problems with the Python communication (I've only tested on
> GNU/Linux and my guess is it doesn't work out-of-box on Windows), try:
>
>> octsympy_config ipc_system
>
> I'd be happy to move everything elsewhere at some point, but for now, issue
> tracker is also at GitHub, so please give it a try and file some bugs ;-)
> Help also very much appreciated!
>
> best,
> Colin
>
> --
> Colin Macdonald
> University Lecturer in Numerical Methodologies
> Tutorial Fellow at Oriel College
> University of Oxford
>

How do you implement the communication with python? It seems via
stdout, am I right?

Reply | Threaded
Open this post in threaded view
|

Re: A symbolic package using SymPy

Colin Macdonald
On 18/04/14 17:19, Juan Pablo Carbajal wrote:
> How do you implement the communication with python? It seems via
> stdout, am I right?

Essentially yes.

Two options: system() and popen2().  In both cases I construct the
python commands as strings and pass them to stdin of python.  In case
of system(), Octave does it all for me.

In popen2(), I pass commands to the file descriptor (which is python's
stdin) and then read back from python's stdout.

Its a bit messy, but other more robust implementations could be
dropped in (linking to libpython in a .oct file would be nice!)  Most
of the @sym class doesn't care, just needs *some* mechanism.

(The two mechanisms I'm using don't need anything compiled.)

Colin


Reply | Threaded
Open this post in threaded view
|

Re: A symbolic package using SymPy

Lukas Reichlin-4
In reply to this post by Colin Macdonald
Hi Colin

Very nice! I got it working on OS X 10.9.2 and Octave 3.6.4 from Fink. I had to download and install SymPy by

sudo python setup.py install

I needed

octsympy_config ipc_system

Best regards,
Lukas


On 17.04.2014, at 15:34, Colin Macdonald <[hidden email]> wrote:

> Hi,
>
> I've been tinkering with making a symbolic package using the Python CAS SymPy.  The goal is feature parity with other symbolic packages.
>
> You can try it now, either git clone, or just download a .zip file (which works as a GNU Octave package).
>
> https://github.com/cbm755/octsympy
>
> Here's some examples:
>
> > pkg install octsympy-master.zip
> > pkg load octsympy
> > syms x y z a b c k
> > A = [sin(x/2) floor(exp(x*c)); ...
> acosh(x^(b*c)/pi) ceil(sin(x/gamma(x)))]
> > pretty(A)
> >
> > f = exp(-x^2);
> > F = fourier(f,x,k);
> > pretty(F)
> > g = ifourier(F,k,x);
> > simplify(f - g)
> >
> > limit(1/x, x, 0, 'left')
>
> If you have problems with the Python communication (I've only tested on GNU/Linux and my guess is it doesn't work out-of-box on Windows), try:
>
> > octsympy_config ipc_system
>
> I'd be happy to move everything elsewhere at some point, but for now, issue tracker is also at GitHub, so please give it a try and file some bugs ;-)  Help also very much appreciated!
>
> best,
> Colin
>
> --
> Colin Macdonald
> University Lecturer in Numerical Methodologies
> Tutorial Fellow at Oriel College
> University of Oxford
>