-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
dsolve hangs #11131
Comments
This issue seems to have been fixed on master: In [29]: y = Function('y')(x)
In [30]: dsolve(diff(y, x, x) - 8*cos(x) + sec(x)**2)
Out[30]: y(x) = C₁ + C₂⋅x + log(cos(x)) - 8⋅cos(x) Perhaps @oscarbenjamin will know if there's a need to add a test for this, if it wasn't already. |
I've checked and it is slow in 1.3 (doesn't hang) but it's slow in integrals. It faster in master because it is now solved by nth_algebraic: In [8]: y=Function('y')(x)
...: eq=diff(y,x,x)-8*cos(x)+sec(x)**2
In [9]: classify_ode(eq)
Out[9]:
('nth_algebraic',
'nth_linear_constant_coeff_variation_of_parameters',
'nth_linear_euler_eq_nonhomogeneous_variation_of_parameters',
'nth_algebraic_Integral',
'nth_linear_constant_coeff_variation_of_parameters_Integral',
'nth_linear_euler_eq_nonhomogeneous_variation_of_parameters_Integral') The other solvers don't hang but they are slow and give suboptimal results: In [1]: y=Function('y')(x)
...: eq=diff(y,x,x)-8*cos(x)+sec(x)**2
In [2]: dsolve(eq, hint='nth_linear_euler_eq_nonhomogeneous_variation_of_parameters')
Out[2]:
⌠
⎮ ⎛ 2 ⎞
y(x) = C₁ + C₂⋅x + 8⋅x⋅sin(x) - x⋅tan(x) - ⎮ x⋅⎝8⋅cos(x) - sec (x)⎠ dx
⌡
In [3]: dsolve(eq, hint='nth_linear_constant_coeff_variation_of_parameters')
Out[3]:
⌠
⎛ sin(x)⎞ ⌠ ⎮ 2
y(x) = C₁ + x⋅⎜C₂ + 8⋅sin(x) - ──────⎟ - ⎮ 8⋅x⋅cos(x) dx - ⎮ -x⋅sec (x) dx
⎝ cos(x)⎠ ⌡ ⌡ This is because each method ends up with an integral like:
which takes a while and doesn't evaluate anyway. It could be worth opening a separate issue in integrals about that but I think this is all fixed as far as dsolve is concerned. Simple ODEs like this are now handled in a simple way by nth_algebraic. |
Looks like a simple DE
y=Function('y')(x)
dsolve(diff(y,x,x)-8*cos(x)+sec(x)**2)
The text was updated successfully, but these errors were encountered: