In [ ]:
import sympy as sp
# See: http://docs.sympy.org/latest/tutorial/printing.html
sp.init_printing()
Make one symbol:
In [ ]:
x = sp.symbols("x")
Make several symbols at once:
In [ ]:
x, y, z = sp.symbols("x y z")
In [ ]:
x = sp.symbols("x")
In [ ]:
expr = sp.cos(x) + 1
expr.subs(x, 0)
In [ ]:
x = sp.symbols("x")
In [ ]:
sp.simplify((x**3 + x**2 - x - 1)/(x**2 + 2*x + 1))
In [ ]:
sp.simplify(sp.exp(sp.I * sp.pi) + sp.exp(sp.I * sp.pi))
In [ ]:
x = sp.symbols("x")
In [ ]:
sp.factor(x**3 - x**2 + x - 1)
In [ ]:
x = sp.symbols("x")
In [ ]:
sp.expand((x - 1)*(x**2 + 1))
In [ ]:
x = sp.symbols("x")
In [ ]:
eq = sp.Eq(x**2, 1)
In [ ]:
sp.solveset(eq, x)
In [ ]:
x, y, z = sp.symbols("x y z")
In [ ]:
sp.Derivative(sp.cos(x), x)
In [ ]:
diff = sp.Derivative(sp.cos(x), x)
diff
In [ ]:
diff.doit()
In [ ]:
sp.diff(sp.cos(x), x)
In [ ]:
expr = sp.exp(x*y*z)
diff = sp.Derivative(expr, x, y, y, z, z, z, z)
sp.Eq(diff, diff.doit())
In [ ]:
diff = sp.Derivative(sp.cos(x), x)
sp.Eq(diff, diff.doit())
In [ ]:
diff = sp.Derivative(3*sp.cos(x)**2, x)
sp.Eq(diff, diff.doit())
In [ ]:
diff = sp.Derivative(sp.exp(x**2), x)
sp.Eq(diff, diff.doit())
In [ ]:
diff = sp.Derivative(x**4, x, 2)
sp.Eq(diff, diff.doit())
or
In [ ]:
diff = sp.Derivative(x**4, x, x)
sp.Eq(diff, diff.doit())
In [ ]:
diff = sp.Derivative(x**4, x, 3)
sp.Eq(diff, diff.doit())
or
In [ ]:
diff = sp.Derivative(x**4, x, x, x)
sp.Eq(diff, diff.doit())
In [ ]:
diff = sp.Derivative(sp.exp(x*y), x, y)
sp.Eq(diff, diff.doit())
In [ ]:
diff = sp.Derivative(sp.exp(x*y*z), x, y, y, z, z, z, z)
sp.Eq(diff, diff.doit())
In [ ]:
x, y, z = sp.symbols("x y z")
In [ ]:
sp.Integral(sp.cos(x), x)
In [ ]:
integ = sp.Integral(sp.cos(x), x)
integ
In [ ]:
integ.doit()
In [ ]:
sp.integrate(sp.cos(x), x)
In [ ]:
integ = sp.Integral(sp.cos(x), x)
sp.Eq(integ, integ.doit())
In [ ]:
integ = sp.Integral(sp.cos(x), x)
sp.Eq(integ, integ.doit())
sp.oo
means infinity.
In [ ]:
integ = sp.Integral(sp.cos(x), (x, -sp.oo, sp.oo))
sp.Eq(integ, integ.doit())
In [ ]:
integ = sp.Integral(sp.cos(x), (x, -sp.pi, sp.pi))
sp.Eq(integ, integ.doit())
In [ ]:
integ = sp.Integral(sp.exp(-x), (x, 0, sp.oo))
sp.Eq(integ, integ.doit())
In [ ]:
integ = sp.Integral(sp.cos(x), (x, -sp.oo, sp.oo), (x, -sp.oo, sp.oo))
sp.Eq(integ, integ.doit())
In [ ]:
integ = sp.Integral(sp.cos(x**2 + y**2), (x, -sp.oo, sp.oo), (y, -sp.oo, sp.oo))
sp.Eq(integ, integ.doit())