# Re: [sympy] How to specify proprties of a constant

Use

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

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
> 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
> .
> 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