SymPy
From Wikipedia, the free encyclopedia
SymPy | |
---|---|
Developed by | Independent group of people |
Latest release | 0.5.15 / May 24, 2008 |
Written in | Python |
OS | Cross-platform |
Genre | Computer algebra system |
License | New BSD license |
Website | http://code.google.com/p/sympy/ |
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 and is easy to install and get started with. 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*b -> 3*a*b^2)
- expansion (like (a+b)^2 -> a^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 x -> ln(x), or sin -> cos)
- 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
- SAGE: an open source alternative to Mathematica, Maple, Matlab and Magma (SymPy is included in SAGE)
- mpmath: a Python library for arbitrary-precision floating-point arithmetic (included in SymPy)
- sympycore: a fork of the SymPy core package (see SymPyCore for more information)
- symbide: GUI for SymPy in PyGTK
- symfe: Lightweight symbolic finite element calculations in Python
[edit] Usage examples
Differentiation:
>>> from sympy import * >>> x,y = symbols('x', 'y') >>> 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)
Plotting:
>>> from sympy import * >>> Plot(cos(x*3)*cos(y*5)-y) [0]: -y + cos(3*x)*cos(5*y), 'mode=cartesian'