Wrong Answer in the sympy.dsolve for ode

42 views
Skip to first unread message

kang li

unread,
Apr 7, 2022, 9:43:18 PM4/7/22
to sympy
Snipaste_2022-04-08_02-41-56.png

kang li

unread,
Apr 7, 2022, 9:58:45 PM4/7/22
to sympy
Snipaste_2022-04-08_02-58-10.png

On Friday, April 8, 2022 at 2:43:18 AM UTC+1 kang li wrote:
Snipaste_2022-04-08_02-41-56.png

Aaron Meurer

unread,
Apr 8, 2022, 6:32:20 PM4/8/22
to sy...@googlegroups.com
It does look wrong, according to checkodesol(). Can you open an issue
in the SymPy issue tracker for this?

Aaron Meurer

On Thu, Apr 7, 2022 at 7:58 PM kang li <kang.mat...@gmail.com> wrote:
>
>
>
> On Friday, April 8, 2022 at 2:43:18 AM UTC+1 kang li wrote:
>>
>>
> --
> 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 view this discussion on the web visit https://groups.google.com/d/msgid/sympy/ffad897b-afc7-4d36-adde-635f3174c0cfn%40googlegroups.com.

Oscar Benjamin

unread,
Apr 8, 2022, 7:13:44 PM4/8/22
to sympy
It is wrong or at least useless since B(t) appears in the integral. A
correct and simple result is given by the 1st_linear hint:

In [111]: dsolve(expr, hint='1st_linear')
Out[111]:
⎛ ⌠ ⎞
⎜ ⎮ ⌠ ⎟ ⌠
⎜ ⎮ -⎮ a(t) dt ⎟ ⎮ a(t) dt
⎜ ⎮ ⌡ ⎟ ⌡
B(t) = ⎜C₁ - ⎮ ℯ dt⎟⋅ℯ
⎝ ⌡ ⎠

In [112]: sol = dsolve(expr, hint='1st_linear')

In [113]: checkodesol(expr, sol)
Out[113]: (True, 0)

The incorrect result comes from the 1st_exact solver. It's possible
that 1st_exact shouldn't match this or that there's a bug in the
1st_exact solver.

--
Oscar
> To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/CAKgW%3D6JFo15_c0Lb6x-emfi3OFs_i%2BwOZpQvNMMt8PLBBnDPfQ%40mail.gmail.com.

emanuel.c...@gmail.com

unread,
Apr 8, 2022, 7:20:58 PM4/8/22
to sympy

FWIW :

sage: var("t")
t
sage: B=function("B")
sage: a=function("a")
sage: de=B(t).diff(t)-a(t)*B(t)+1==0
sage: foo=desolve(de,B(t), ivar=t) ; foo
(_C - integrate(e^(-integrate(a(t), t)), t))*e^(integrate(a(t), t))

which checks :

sage: var("_C")
_C
sage: de.substitute_function(B,foo.function(t))
0 == 0

HTH,

kang li

unread,
Apr 18, 2022, 3:20:04 AM4/18/22
to sympy
Sure, here is the link to this issue. https://github.com/sympy/sympy/issues/23380
Reply all
Reply to author
Forward
0 new messages