DMelt:Symbolic/5 SimPy

From HandWiki
Limitted access. First login to DataMelt member area if you are a full DataMelt member.

Using SimPy engine

SimPy is a pure Python library and this means you might find it a bit slower than using the pure-Java calculations based on Jasymca. Let us show a simple SymPy example. Start DataMelt IDE and type:

from sympy import *
 var('x y')
 Rational(3,2)*pi + exp(I*x) / (x**2 + y)

The output of this code is

(3/2)*pi + 1/(y + x**2)*exp(I*x)

Look at other SymPy example in this wiki.

Check out a few other examples:

Calculate an integral

from sympy import *
 var('x')
 integrate(x**2 * cos(x), x)

The output is:

-2*sin(x) + x**2*sin(x) + 2*x*cos(x)

Solve an equation

from sympy import *
 var('x y')
 solve([Eq(x + 5*y, 2), Eq(-3*x + 6*y, 15)], [x, y])

The output is:

{x: -3, y: 1}

Integration

DataMelt extends SimPy and integrates it into Java. Below we show an advanced example of how to plot a function and its differential on the same plot.

No access. To show this code, login to DataMelt member area

The output figure is shown below:

DMelt example: Differentiation using SymPy