Tuesday, January 27, 2009

sympy

version 0.6.3 of sympy has c and python code generation. now i can do symbolic math and have very fast computation of the resulting expressions. cool! In [2]: f = sympy.sympify('exp(-x**2)') In [3]: sympy.printing.ccode(f) Out[3]: 'exp(-pow(x,2))' In [4]: sympy.printing.python(f) Out[4]: "x = Symbol('x')\ne = exp(-x**2)" also has some built-in plotting, which would be more interesting if it weren't so dangerous (pyglet crashed x twice now). but it does have plotting.textplot, which is a cheap and easy way to plot stuff in a terminal. brings back memories of the ol' hp48g. the mpmath module that comes with sympy also has a plot module that promises convenient expression plotting. too bad it doesn't seem to work yet.

1 comment:

Fredrik Johansson said...

The plotting in mpmath does work. What error are you getting? Perhaps you haven't installed matplotlib?