Hi Leonid,
Thank you for spending time for my problem. 
Your answer is very clear.
Regards,
Dabitto

Le jeudi 28 décembre 2017 19:48:05 UTC+1, Leonid Kovalev a écrit :
>
> 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/a9332c79-8b9e-4265-99f3-203e75dd02a2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to