Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagepy
>>> from sympy import *

>>> x = Symbol('x')
>>> y = Symbol('y')

Then You may then manipulate them as you want:

...

Some regular constants are already included in SymPy as symbols, like e, pi and infinite (oo)evalf() evaluates the symbols as floation-point numbers.

...

Code Block
languagepy
>>> integrate(exp(-x), (x, 0, oo))
1

>>> integrate(log(x), (x, 0, 1))
-1

Algebraic equations

SymPy is able to solve algebraic equations with one or several variables. solve(equation, variable) takes as first argument an equation that is supposed to be equaled to 0, and as second argument the unknown variable. In case of multiple equations and variables, solve returns a dictonary containing the results.

Code Block
languagepy
>>> from sympy import *
>>> solve(x**2 - 1, x)
[-1, 1]


>>> solve([x + 5*y - 2, -3*x + 6*y - 15], [x, y])
{x: -3, y: 1}


>>> solve(Eq(x**4, 1), x)
[-1, 1, -I, I]