Hi,
I'm creating an example for using SymPy, using the good old harmonic oscillator as an example:
import sympy
s = sympy.Function("s")
t, zeta, m, k = sympy.symbols("t, zeta, m, kappa")
expr = sympy.Eq(m*s(t).diff(t, t), -k*s(t))
sympy.dsolve(expr, s(t), ics={s(t).diff(t,1).subs(t,0):0})
The latex form of the output is:
s{\left (t \right )} =
C_{1} e^{- t \sqrt{- \frac{\kappa}{m}}} +
C_{2} e^{t \sqrt{- \frac{\kappa}{m}}}
This gives a nice and generic result, but a bit too generic to my taste. For instance the constants m and k are both positive, and with that knowledge it is easy to express teh result using sine and cosine functions (and with the constraint: only a cosine).
How do I tell SymPy that m and k are > 0?
Best,
Maarten