##// END OF EJS Templates
Updating notebook examples.
Updating notebook examples.

File last commit:

r4335:c9ad4e85
r4335:c9ad4e85
Show More
sympy.ipynb
1 line | 1.8 KiB | text/plain | TextLexer

SymPy: Open Source Symbolic Mathematics

In [1]:
%load_ext sympyprinting
In [2]:
from __future__ import division
from sympy import *
x, y, z = symbols("x y z")
k, m, n = symbols("k m n", integer=True)
f, g, h = map(Function, 'fgh')

Elementary operations

In [3]:
Rational(3,2)*pi + exp(I*x) / (x**2 + y)
In [4]:
exp(I*x).subs(x,pi).evalf()
In [5]:
e = x + 2*y
In [6]:
srepr(e)
In [7]:
exp(pi * sqrt(163)).evalf(50)

Algebra

In [8]:
((x+y)**2 * (x+1)).expand()
In [9]:
a = 1/x + (x*sin(x) - 1)/x
display(a)
simplify(a)
In [10]:
solve(Eq(x**3 + 2*x**2 + 4*x + 8, 0), x)
In [11]:
a, b = symbols('a b')
Sum(6*n**2 + 2**n, (n, a, b))

Calculus

In [12]:
limit((sin(x)-x)/x**3, x, 0)
In [13]:
(1/cos(x)).series(x, 0, 6)
In [14]:
diff(cos(x**2)**2 / (1+x), x)
In [15]:
integrate(x**2 * cos(x), (x, 0, pi/2))
In [16]:
eqn = Eq(Derivative(f(x),x,x) + 9*f(x), 1)
display(eqn)
dsolve(eqn, f(x))
In [40]:
%notebook save sympy.ipynb
In [41]:
%notebook load basic_quantum.ipynb