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
problem when using dsolve() to solve ordinary differential equations #16635
Comments
Thanks for reporting this. Here is simpler code to reproduce this: from sympy import *
t = symbols('t')
l_1 = Function('l_1')
l_2 = Function('l_2')
eqs = [
Eq(l_1(t).diff(t), + l_1(t) - l_2(t) + 15*t - 10),
Eq(l_2(t).diff(t), + l_1(t) - l_2(t) - 15*t - 5),
]
pprint(eqs[0])
pprint(eqs[1])
l_t = dsolve(eqs, [l_1(t), l_2(t)])
pprint(l_t) The ODEs are:
Traceback:
These should be solvable as the system is constant coefficient non-homogeneous (CCNH). Various special cases of CCNH are solvable for systems of 2 or 3 equations. These can be solved in general using the matrix exponential but it isn't implemented yet in dsolve. |
I'm having the same issue on the following system of ODEs:
System pprint:
|
That's a different problem actually. The dsolve system code lacks the capability to solve an integrable system of ODEs. It needs to the equivalent of the |
Ouch. That basically eliminates most/many/all physics based ODEs describing dynamic systems. Was hoping to use sympy as a replacement for Matlab symbolic math, but doesn't sound like the maturity is there just yet. |
You've misunderstood what I meant by "integrable" I think. What I mean is: trivial ODE systems that can be solved simply by integration. There isn't currently a solver implemented just for that. It wouldn't be hard to add though. |
Nah, we're on the same page, and I understand the work-around. I'd imagine this would be a common use-case though, and would be a useful feature. |
If anyone wants to write a pull request this we just need to do the same as nth_algebraic does for single ODEs. The nth_algebraic solver replaces derivatives with a "function" whose inverse is an integral: Lines 4574 to 4579 in ac1eaa2
Then the system of ODEs can be solved by solve as if it were a system of algebraic equations:Line 4623 in ac1eaa2
We already have that implemented for single ODEs so the code there can be reused. We just need to find a place in the systems matching code to try this and see if it works. |
Closes sympy/sympy#16635 Closes sympy/sympy#14312 Closes sympy/sympy#8859 Closes sympy/sympy#9204
Closes sympy/sympy#16635 Closes sympy/sympy#14312 Closes sympy/sympy#8859 Closes sympy/sympy#9204
@oscarbenjamin I missed this issue when we were working in the type 2 solver. This issue can be closed now.
|
I will add a regression test case for the same in the current PR. |
It can be closed when the regression test is merged to master |
When I use dsolve() like this, I get an error in the last
How can I solve it, thank you!
The text was updated successfully, but these errors were encountered: