3 ms·
Sympy is pretty awesome. I use live.sympy.org a lot with my students because you can bookmark an entire interactive session as a (long) URL. For example, suppos
by ivan_ah 13y ago
Sympy is pretty awesome. I use live.sympy.org a lot with my students because you can bookmark an entire interactive session as a (long) URL. For example, suppose you had to answer the following question. Find the position of the object at t=3 seconds, if it starts from x_i=20[m], with v_i=10[m/s] and undergoes a constant acceleration of a=5[m/s^2].
Ans: 72.5[m]. Sol.: http://bit.ly/1hJS9P3 http://bit.ly/1hJS9P3
Below are some more examples of cool stuff sympy can do.
Expand, factor, and solve polynomials:
>>> P = (x-1)*(x-2)*(x-3)
>>> P.expand()
x**3 - 6*x**2 + 11*x - 6
>>> P.factor()
(x - 1)*(x - 2)*(x - 3)
>>> roots = solve(P,x)
>>> roots
[1, 2, 3]
Derive the solutions of a quadratic equation:
>>> solve( a*x**2 + b*x + c, x)
[(-b + sqrt(-4*a*c + b**2))/(2*a), -(b + sqrt(-4*a*c + b**2))/(2*a)]
Compute symbolic outputs of trig functions:
>>> sin(pi/6)
1/2
>>> cos(pi/6)
sqrt(3)/2
Sympy knows about trig identities:
>>> sin(x) == cos(x - pi/2)
True
>>> simplify( sin(x)*cos(y)+cos(x)*sin(y) )
sin(x + y)
>>> e = sin(x)**2 + cos(x)**2
>>> trigsimp(e)
1
Find the solution to the simple harmonic oscillator differential equation (x''(t)+w^2x(t)=0):
>>> sol = dsolve( diff(x(t),t,t) + w**2*x(t), x(t) )
>>> sol
x(t) == C1*sin(w*t) + C2*cos(w*t)
For v4.1 of my math book, I'm going to add a short sympy tutorial. I'll post a printable version of it to HN when I release, so stay tuned ;)
- krastanov 13y agoI am certain that the sympy mailing list would be extremely happy to hear more about your use of live.sympy.org. Especially if you have any suggestions or requests.