-
-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Closed
Labels
Wrong ResultThe output produced by SymPy is mathematically incorrect.The output produced by SymPy is mathematically incorrect.solvers.dsolvesolvers.dsolve.system
Description
dsolve gives wrong solutions of the following 3 by 3 homogeneous linear system. Specifically, the first equation is the one not being satisfied by the solution. If the equations are reordered, the solution changes so that again, 2nd and 3rd equations are satisfied but the 1st is not. From Stack Overflow
k2, k3, t = symbols('k2 k3 t')
x, y, z = symbols('x y z', cls=Function)
eq1 = (Eq(Derivative(x(t),t), k3*y(t)), Eq(Derivative(y(t),t), -(k3+k2)*y(t)), Eq(Derivative(z(t),t), k2*y(t)))
sol1 = dsolve(eq1)
print([eqn.subs({e.lhs: e.rhs for e in sol1}).doit().simplify() for eqn in eq1])
eq2 = (Eq(Derivative(z(t),t), k2*y(t)), Eq(Derivative(x(t),t), k3*y(t)), Eq(Derivative(y(t),t), -(k3+k2)*y(t)))
sol2 = dsolve(eq2)
print([eqn.subs({e.lhs: e.rhs for e in sol2}).doit().simplify() for eqn in eq2])
Expected output: [True, True, True] for both solutions. Actual output from current master:
[Eq(-C3*k3*(k2 + k3)*exp(-t*(k2 + k3))/k2, (C2*k2*exp(t*(k2 + k3)) - C3*k3*(k2 + k3))*exp(-t*(k2 + k3))/k2), True, True]
and
[Eq(C3*k2*exp(-t*(k2 + k3)), C2 + C3*k2*exp(-k2*t - k3*t)), True, True]
Metadata
Metadata
Assignees
Labels
Wrong ResultThe output produced by SymPy is mathematically incorrect.The output produced by SymPy is mathematically incorrect.solvers.dsolvesolvers.dsolve.system