sympy and IVP

94 views
Skip to first unread message

ali...@gmail.com

unread,
Oct 15, 2014, 4:08:30 PM10/15/14
to sy...@googlegroups.com
I run sympy version

sympy
0.7.5-git


I have a problem in solving IVP's with sympy

for example (LaTeX code below)

\[
0.2 \frac{d^2y}{dt^2}+1.2 \frac{dy}{dt}+2y=5 \cos 4t,\quad y(0)=1/2,\quad
y'(0)=0.
\]


Do you have any hints?

Sergey Kirpichev

unread,
Oct 15, 2014, 7:35:17 PM10/15/14
to sy...@googlegroups.com


On Thursday, October 16, 2014 12:08:30 AM UTC+4, ali...@gmail.com wrote:
I have a problem in solving IVP's with sympy [...] Do you have any hints?

We don't support initial conditions yet (issue 4720).  Please read documentation.

However, in this case you can find a generic solution for this ODE with dsolve.  Then, just
substitute initial values and find unknown coefficients with solve.

Aaron Meurer

unread,
Oct 15, 2014, 7:42:48 PM10/15/14
to sy...@googlegroups.com
Initial conditions are supported, but only in the git version.

Aaron Meurer
> --
> 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+un...@googlegroups.com.
> To post to this group, send email to sy...@googlegroups.com.
> Visit this group at http://groups.google.com/group/sympy.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/sympy/8c6f8052-6666-466b-b3dc-31de9249f28a%40googlegroups.com.
>
> For more options, visit https://groups.google.com/d/optout.

Sergey B Kirpichev

unread,
Oct 15, 2014, 8:30:58 PM10/15/14
to sy...@googlegroups.com
On Wed, Oct 15, 2014 at 06:42:20PM -0500, Aaron Meurer wrote:
> Initial conditions are supported, but only in the git version.

I don't think so:
In [4]: dsolve(Eq(diff(y(t),t)-y(t),0),y(t),ics={y(0): 1})
Out[4]:
t
y(t) = C₁⋅ℯ

Or there is something completely undocumented.

Aaron Meurer

unread,
Oct 17, 2014, 2:19:08 AM10/17/14
to sy...@googlegroups.com
We should remove this if it doesn't actually work (or better, make it work).

Aaron Meurer
> --
> 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+un...@googlegroups.com.
> To post to this group, send email to sy...@googlegroups.com.
> Visit this group at http://groups.google.com/group/sympy.
> To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/20141016002922.GA30619%40darkstar.order.hcn-strela.ru.

Sergey B Kirpichev

unread,
Oct 17, 2014, 5:56:50 AM10/17/14
to sy...@googlegroups.com
On Fri, Oct 17, 2014 at 01:18:40AM -0500, Aaron Meurer wrote:
> We should remove this if it doesn't actually work (or better, make it work).

I does work exactly as it was documented in the docstring:
"For now initial conditions are implemented only for
power series solutions of first-order differential equations [...]"

Aaron Meurer

unread,
Oct 18, 2014, 3:57:46 PM10/18/14
to sy...@googlegroups.com
In that case we should raise NotImplementedError when a different
method is used. Putting initial conditions in and not getting a result
makes it feel like you did something wrong.

Aaron Meurer
> --
> 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+un...@googlegroups.com.
> To post to this group, send email to sy...@googlegroups.com.
> Visit this group at http://groups.google.com/group/sympy.
> To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/20141017095544.GA14928%40darkstar.order.hcn-strela.ru.

Ondřej Čertík

unread,
Oct 20, 2014, 11:32:57 AM10/20/14
to sympy
On Wed, Oct 15, 2014 at 2:08 PM, <ali...@gmail.com> wrote:
> I run sympy version
>
> sympy
> 0.7.5-git
>
>
> I have a problem in solving IVP's with sympy

In case somebody is wondering like I was, IVP means initial value
problem (http://en.wikipedia.org/wiki/Initial_value_problem). Google
search for IVP doesn't show this as the first link.

Ondrej

>
> for example (LaTeX code below)
>
> \[
> 0.2 \frac{d^2y}{dt^2}+1.2 \frac{dy}{dt}+2y=5 \cos 4t,\quad y(0)=1/2,\quad
> y'(0)=0.
> \]
>
>
> Do you have any hints?
>
> --
> 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+un...@googlegroups.com.
> To post to this group, send email to sy...@googlegroups.com.
> Visit this group at http://groups.google.com/group/sympy.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/sympy/71f8f788-a051-4bb3-8160-2490b02e56d2%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages