Download sympy cheat sheet

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
SymPy Cheatsheet (http://sympy.org)
Geometry
Basics
Sympy help:
Declare symbol:
Substitution:
Numerical evaluation:
Expanding:
Common denominator:
Simplify expression:
Constants
π:
e:
∞:
i:
pi
E
oo
I
help(function)
x = Symbol(’x’)
expr.subs(old, new)
expr.evalf()
expr.expand()
ratsimp(expr)
simplify(expr)
Integer(x)
Rational(p, q)
Float(x)
Basic funtions
Trigonometric:
Cyclometric:
Hyperbolic:
Area hyperbolic:
Exponential:
Square root:
Logarithm (logb a):
Natural logarithm:
Gamma (Γ(x)):
Absolute value:
sin cos tan cot
asin acos atan acot
sinh cosh tanh coth
asinh acosh atanh acoth
exp(x)
sqrt(x)
log(a, b)
log(a)
gamma(x)
abs(x)
Calculus
lim f (x):
x→a
limit(f, x, a)
lim f (x):
limit(f, x, a, dir=’-’)
lim f (x):
limit(f, x, a, dir=’+’)
x→a−
x→a+
d
f (x):
dx
∂
∂x
R f (x, y):
f (x) dx :
Rb
f (x) dx :
a
Taylor series (at a, deg n)
Points:
Lines:
Circles:
Triangles:
Area:
Intersection:
Checking tangency:
a = Point(xcoord, ycoord)
l = Line(pointA, pointB)
c = Circle(center, radius)
t = Triangle(a, b, c)
object.area
intersection(a, b)
c.is_tangent(l)
diff(f, x)
diff(f, x)
integrate(f, x)
integrate(f, (x, a, b))
f.series(x, a, n)
Plot:
Zoom: +/−:
Rotate X,Y axis:
Rotate Z axis:
View XY:
View XZ:
View YZ:
View Perspective:
Axes Visibility:
Axes Colors:
Screenshot:
Exit plot:
Plot(f, [a, b])
R/F or PgUp/PgDn or Numpad +/Arrow Keys or WASD
Q and E or Numpad 7 and 9
F1
F2
F3
F4
F5
F6
F8
ESC
Discrete math
Factorial (n!):
Binomial coefficient nk :
P
Sum ( bn=a expr):
Q
Product ( bn=a expr):
factorial(n)
binomial(n, k)
summation(expr, (n, a, b))
product(expr, (n, a, b))
Expand (x + y)2 (x − y)(x2 + y):
((x + y)**2 * (x - y) * (x**2 + y)).expand()
1
x sin x − 1
+
:
x
x2 − 1
simplify((1/x) + (x * sin(x) - 1)/(x**2 - 1))
Simplify
Matrix definition:
Determinant:
Inverse:
Identity matrix n × n:
Zero matrix n × n:
Ones matrix n × n:
Equations
solve(f, x)
solve([f, g], [x, y])
dsolve(equation, f(x))
Check if line passing through points (0, 1) and (1, 1)
is tangent to circle with center at (5, 5) and radius 3:
Circle(Point(5,5), 3).is_tangent(
Line(Point(0,1), Point(1,1)))
Find roots of x4 − 4x3 + 2x2 − x = 0:
solve(x**4 - 4*x**3 + 2*x**2 - x, x)
Solve the equations system: x + y = 4, xy = 3:
solve([x + y - 4, x*y - 3], [x, y])
Calculate limit of the sequence
limit(n**(1/n), n, oo)
√
n
n:
Calculate left-sided limit of the function
limit(abs(x)/x, x, 0, dir=’-’)
in 0:
P
2
Calculate the sum 100
n=0 n :
summation(n**2, (n, 0, 100))
m = Matrix([[a, b], [c, d]])
m.det()
m.inv()
eye(n)
zeros(n)
ones(n)
R
Calculate the integral cos3 x dx:
integrate(cos(x)**3, x)
R∞
Calculate the integral 1 xdx2 :
integrate(1/x**2, (x, 1, oo))
Find 10 terms of series expansion of
(1/(1 - 2*x)).series(x, 0, 10)
LATEX print:
Python print:
Pretty print:
|x|
x
P
1
Calculate the sum ∞
n=0 n2 :
summation(1/n**2, (n, 0, oo))
Linear algebra
Printing
Equation f (x) = 0:
System of equations:
Differential equation:
Find 100 digits of π e :
(pi**E).n(100)
Plotting
Numbers types
Integers (Z):
Rationals (Q):
Reals (R):
Examples
print latex()
print python()
pprint()
00
1
1−2x
at 0:
Solve the differential equation f (x) + 9f (x) = 1:
dsolve(f(x).diff(x, x) + 9*f(x) - 1, f(x))
Related documents