I'm using SymPy version 0.7.3, and encountered some problems when using dsolve function. It seems that dsolve having difficulties when the input equation has too many parameters.
I've tried solving the following equation:
from sympy import *
p = Function('p')
t, u1, u2, u3, u4, u5 = symbols('t u1 u2 u3 u4 u5')
eq = Eq(Derivative(p(t),t), -(u3 + u4)*p(t) + exp(-t*(u1 + u2)))
eq
Out: Derivative(p(t), t) == (-u3 - u4)*p(t) + exp(-t*(u1 + u2))
%time dsolve(eq)
And got:
CPU times: user 213.11 s, sys: 0.00 s, total: 213.11 s
Wall time: 213.12 s
p(t) == (C1 + Piecewise((t*u1/(u1 + u2) + t*u2/(u1 + u2), u3 == u1 + u2 - u4), (-exp(t*u3)*exp(t*u4)/(u1*exp(t*u1)*exp(t*u2) + u2*exp(t*u1)*exp(t*u2) - u3*exp(t*u1)*exp(t*u2) - u4*exp(t*u1)*ex
p(t*u2)), True)))*exp(-t*(u3 + u4))
(Took 213.12 seconds!)
Then I've replaced u1+u2 by u5:
eq = Eq(Derivative(p(t),t), -(u3 + u4)*p(t) + exp(-t*(u1 + u2))).subs(u1+u2, u5)
eq
Out:Derivative(p(t), t) == (-u3 - u4)*p(t) + exp(-t*u5)
%time dsolve(eq)
and got:
CPU times: user 1.62 s, sys: 0.00 s, total: 1.62 s
Wall time: 1.62 s
p(t) == (C1 + Piecewise((t, u3 == -u4 + u5), (exp(t*u3)*exp(t*u4)/(u3*exp(t*u5) + u4*exp(t*u5) - u5*exp(t*u5)), True)))*exp(-t*(u3 + u4))
(Only 1.62 seconds!)
I've tried using different hints but it didn't help...
I've also noticed that in much more complex functions, dsolve crashes, but when replacing some of the constant parameters, it works fast.
Do you know what is the reason for this phenomena? Is there any way to solve this problem automatically?