Use
m, k = symbols("m, kappa", positive=True)

##
Advertising

Aaron Meurer
On Thursday, September 22, 2016, <maarten.sn...@knmi.nl> wrote:
> 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
>
> --
> You received this message because you are subscribed to the Google Groups
> "sympy" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to sympy+unsubscr...@googlegroups.com.
> To post to this group, send email to sympy@googlegroups.com.
> Visit this group at https://groups.google.com/group/sympy.
> To view this discussion on the web visit https://groups.google.com/d/ms
> gid/sympy/52da57bb-dffe-4a98-b024-d0a7c8c99e98%40googlegroups.com
> <https://groups.google.com/d/msgid/sympy/52da57bb-dffe-4a98-b024-d0a7c8c99e98%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>
--
You received this message because you are subscribed to the Google Groups
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to sympy+unsubscr...@googlegroups.com.
To post to this group, send email to sympy@googlegroups.com.
Visit this group at https://groups.google.com/group/sympy.
To view this discussion on the web visit
https://groups.google.com/d/msgid/sympy/CAKgW%3D6KZrs5SWE9pmr-OXAm%3DPrf0_pjaQmbw0tEUUaAHyV2adQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.