%pylab inline import seaborn style.use('seaborn-poster') import sympy sympy.init_printing() 1 + 1 / (1 + 1 / (1 + 1 / ( 1 + 1/2))) 1 + 1 / (1 + 1 / (1 + 1 / (1 + 1 / (1 + 1 / (1 + 1 / (1 + 1 / (1 + 1 / ( 1 + 1/2)))))))) sympy.GoldenRatio sympy.GoldenRatio.evalf(100) str(sympy.Rational(1, 97).evalf(1000)) phi = [sympy.Integer(1)] for i in range(30): phi.append(1 + 1 / phi[-1]) phi, phi[-1].evalf(20) 1 + (1 / sympy.GoldenRatio).evalf(20) (1/(sympy.GoldenRatio - 1)).evalf(20) eps = sympy.Symbol(r"\varepsilon") m2 = sympy.Matrix([[1, 0], [eps, 1]]) m2 m1 = sympy.Matrix([[1, -eps], [0, 1]]) m1 m3 = m2 * m1 m3 [m.det() for m in [m1, m2, m3]] m3.LUdecomposition() m3.eigenvects(simplify=True) m3.inv() m3.inv().LUdecomposition() P, D = m3.diagonalize() P, D, P.inv() sympy.simplify(P.inv()) print(sympy.latex(m3.inv().LUdecomposition())) m3.replace(eps, .01).eigenvects() m3.subs(eps, 2).eigenvects() m3.subs(eps, 2.01).eigenvects() m4 = (m3*m3).expand() m4 m5 = (m4 * m4).expand() m5 m5.subs(eps, .01) m6 = (m5 * m5).expand() m6 m6.subs(eps, .01) c = m6.dot(sympy.Matrix([[1, 0]]))[0] c sympy.plot(c, m6.dot(sympy.Matrix([[1, 0]]))[1], (eps, -1.9, 1.9)); v = sympy.Matrix([[1, 0]]) circle = [v] mf = m3.subs(eps, 2**-5) for i in range(256): v = mf.dot(v) circle.append(v) plot(circle) circle[:5] plot([x for x, y in circle], [y for x, y in circle], 'o', markersize=1) None sympy.Integral(sympy.sqrt(1/eps), eps) import sympy.printing.dot import os os.popen('dot -Tx11', 'w').write(sympy.printing.dot.dotprint(m6[0])) x, y = sympy.symbols('x y') x, y integ = sympy.Integral(x**y * sympy.exp(-x), (x, 0, sympy.oo)) integ integ.doit() print(sympy.latex(integ.doit())) print(sympy.pretty(integ.doit())) sympy.srepr(integ.doit()) ido = integ.doit() ido.func, ido.args, ido.args[0].func from sympy.functions.elementary.piecewise import Piecewise, ExprCondPair box = Piecewise(ExprCondPair(sympy.Integer(0), sympy.StrictLessThan(x, 0)), ExprCondPair(sympy.Integer(1), sympy.StrictLessThan(x, 1)), ExprCondPair(sympy.Integer(0), sympy.S.true)) box print(sympy.latex(box)) [box.subs(x, i) for i in [-1, -0.5, 0, 0.5, 1, 1.5]] sympy.plot(x**2, (x, -1, 2)) sympy.plot(box, (x, -1, 2)) sympy.var('ohshit') ohshit sympy.symbols('x0 y37 foo1') x0 [sympy.Eq(f(x), f(x).rewrite(sympy.exp)) for f in [sympy.sin, sympy.cos, sympy.tan]] sympy.cos(x).rewrite(sympy.exp).factor() ((x+y)**14).expand() sympy.factorint(3801372, visual=True) import sympy.utilities.autowrap sympy.utilities.autowrap??