dsolve produces an incorrect result?

34 views
Skip to first unread message

Dan Lewis

unread,
Jun 28, 2016, 11:22:39 AM6/28/16
to sympy
Hi folks,

Looks like sympy/dsolve produces an incorrect solution to an ODE:

from sympy import *
mass, g, b, t = symbols('mass g b t')
v, x = symbols('v x', cls=Function)
paraChute = mass*v(t).diff(t)-mass*g+b*(v(t))**2
solution = dsolve(paraChute,v(t),hint='lie_group')
solution
Out[1]:
Eq(v(t), sqrt(g)*sqrt(mass)/(sqrt(b)*tanh(sqrt(b)*sqrt(g)*(C1*mass + t)/sqrt(mass))))

Sorry in advance if I'm doing something silly - the solution shouldn't be 1/tanh.  Should be tanh.

Aaron Meurer

unread,
Jun 28, 2016, 12:54:29 PM6/28/16
to sy...@googlegroups.com
According to checkodesol(paraChute, solution), the solution is correct.

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 https://groups.google.com/group/sympy.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/sympy/92f8fe37-45df-4cc0-9ebc-7330f0bb20d9%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Aaron Meurer

unread,
Jun 28, 2016, 12:59:57 PM6/28/16
to sy...@googlegroups.com
The reason this is happening is that both tanh(x) and coth(x) satisfy
the same differential equation, namely f'(x) = 1 - f(x)**2, because
d/dx tanh(x) = 1 - tanh(x)**2 and d/dx coth(x) = 1 - coth(x)**2. This
is your ODE (up to a change in variable).

Aaron Meurer

Aaron Meurer

unread,
Jun 28, 2016, 1:07:51 PM6/28/16
to sy...@googlegroups.com
In particular, tanh(x + I*pi/2) = coth(x) and coth(x + I*pi/2) =
tanh(x). You can verify this with SymPy:

In [22]: x = Symbol('x', real=True)

In [23]: tanh(x + I*pi/2).expand(complex=True).simplify()
Out[23]:
1
───────
tanh(x)

In [24]: 1/tanh(x + I*pi/2).expand(complex=True).simplify()
Out[24]: tanh(x)

But note that the arbitrary constant in the solution of your ODE is
like coth(a*t + C1). So the solution represents both tanh() and
coth(), depending on the value of C1.

Aaron Meurer

Dan Lewis

unread,
Jun 28, 2016, 8:17:57 PM6/28/16
to sympy
Yikes.  Indeed - being silly and not thinking through my complex numbers.  Thanks for the detailed response(s).
Reply all
Reply to author
Forward
0 new messages