SymPy

From Wikipedia, the free encyclopedia

Jump to: navigation, search
SymPy
Sympy-160px.png
Developer(s) Independent group of people
Stable release 0.6.6 / December 20, 2009; 51 day(s) ago (2009-12-20)
Written in Python
Operating system Cross-platform
Type Computer algebra system
License New BSD license
Website sympy.org
Not to be confused with SimPy, a Python discrete-event simulation language.

SymPy is a Python library for symbolic mathematics. It aims to become a full-featured computer algebra system (CAS) while keeping the code as simple as possible in order to be comprehensible and easily extensible. SymPy is written entirely in Python and does not require any external libraries, except optionally for plotting support.

SymPy is free software. It is currently under active development; the lead developer is Ondřej Čertík.

Contents

[edit] Features

Currently, SymPy core has around 6300 lines of code (including extensive comments and docstrings) and its capabilities include:

  • basic arithmetics *, /, +, -, **
  • basic simplification (like a*b*b + 2*b*a*b3*a*b**2)
  • expansion (like (a+b)**2a**2 + 2*a*b + b**2)
  • functions (exp, ln, ...)
  • complex numbers (like exp(I*x).expand(complex=True)cos(x)+I*sin(x))
  • differentiation
  • Taylor (Laurent) series
  • substitution (like xln(x), or sincos)
  • arbitrary precision integers, rationals and floats
  • noncommutative symbols
  • pattern matching

Then there are SymPy modules (18200 lines including documentation) for these tasks:

  • more functions (sin, cos, tan, atan, asin, acos, factorial, zeta, legendre)
  • limits (like limit(x*log(x), x, 0)0)
  • integration using extended Risch-Norman heuristic
  • polynomials (division, gcd, square free decomposition, groebner bases, factorization)
  • solvers (algebraic, difference and differential equations, and systems of equations)
  • symbolic matrices (determinants, LU decomposition...)
  • Pauli and Dirac algebra
  • geometry module
  • plotting (2D and 3D)

There are extensive tests (6148 lines in 58 files) for every single feature in SymPy.

[edit] Related projects

[edit] Usage examples

Differentiation:

>>> from sympy import *
>>> x,y = symbols('xy')
>>> f = x**2 / y + 2 * x - ln(y)
>>> diff(f,x)
2 + 2*x/y
>>> diff(f,y)
-1/y - x**2*y**(-2)
>>> diff(diff(f,x),y)
-2*x*y**(-2)
Output of the plotting example

Plotting:

>>> from sympy import *
>>> x,y = symbols('xy')
>>> Plot(cos(x*3)*cos(y*5)-y)
[0]: -y + cos(3*x)*cos(5*y), 'mode=cartesian'

[edit] See also

[edit] External links

Languages