Skip to content

Incorrect solution of 3 by 3 linear ODE systems #14312

@normalhuman

Description

@normalhuman

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

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions