The problem is that the solver needs to know the sign of a certain 
expression in terms of the coefficients (the discriminant of a polynomial), 
and it cannot determine the sign based on the information given, as the 
discriminant ends up being `D = (1/(c2*r2) - 1/(c1*r1))**2`. Symbols are 
not automatically assumed real; so the square of some expression like that 
could even be negative. It's a good idea to declare symbols as real, by 
 
sym.symbols('i, r1, c1, r2, c2, t', real=True)

 but this doesn't solve the problem because it might happen that c1*r1 == 
c2*r2, and then D is 0. 

I just edited the source to tell it which branch to choose, and got the 
result:

[Eq(x1(t), C1*exp(t*(-(c1*r1 - c2*r2)/(2*c1*c2*r1*r2) - (c1*r1 + c2*r2)/(2*
c1*c2*r1*r2)))/(c1*r1) + C2*exp(t*((c1*r1 - c2*r2)/(2*c1*c2*r1*r2) - (c1*r1 
+ c2*r2)/(2*c1*c2*r1*r2)))/(c1*r1) + i*(r1 + r2)), Eq(x2(t), C1*(1/(c1*r1) - 
(c1*r1 - c2*r2)/(2*c1*c2*r1*r2) - (c1*r1 + c2*r2)/(2*c1*c2*r1*r2))*exp(t*(-(
c1*r1 - c2*r2)/(2*c1*c2*r1*r2) - (c1*r1 + c2*r2)/(2*c1*c2*r1*r2))) + C2*(1/(
c1*r1) + (c1*r1 - c2*r2)/(2*c1*c2*r1*r2) - (c1*r1 + c2*r2)/(2*c1*c2*r1*r2))*
exp(t*((c1*r1 - c2*r2)/(2*c1*c2*r1*r2) - (c1*r1 + c2*r2)/(2*c1*c2*r1*r2))) + 
i*r2)]

So at least you have your solution... Unfortunately I cannot think of any 
workaround at user level. I think the handling of D here 
<https://github.com/sympy/sympy/blob/master/sympy/solvers/ode.py#L6640> 
should be changed in two ways:

a) test it with D.is_positive etc instead of D>0 which throws the error you 
got
b) if the sign can't be determined, return a Piecewise object listing the 
options with appropriate cases:

Piecewise((sol1, D>0), (sol2, D<0), (sol3, Eq(D, 0)))

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sympy+unsubscr...@googlegroups.com.
To post to this group, send email to sympy@googlegroups.com.
Visit this group at https://groups.google.com/group/sympy.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/b9bf18db-bbb9-4a33-bf55-4fac83db2cf5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to