Thanks for your answer.
However : this was a simplified example in a larger context. The values can 
be arbitrary (for example generated by numerical random number generator) 
and so the use of rationnal is not practical ...
I knew about the fact that simplify is not a in-place method, the last line 
of my previous code was a mistake (however it did not change the result 
displayed for this time). Sorry about that.
Thanks again,
   Mike


Le vendredi 31 juillet 2020 01:43:18 UTC+2, Oscar a écrit :
>
> Have you tried using exact Rational values instead of floats? For example 
> 1e-6 could be Rational(1, 10**6) or S(1)/10**6. It is best to avoid using 
> floats if possible.
>
> Also simplify is not an in-place method so you need to use:
>    H3 = H3.simplify()
> rather than
>    H3.simplify()
>
> -- 
> Oscar
>
> On Sun, 26 Jul 2020 at 21:56, Mikhael Myara <mikhae...@umontpellier.fr 
> <javascript:>> wrote:
>
>> Something weird, I would like to understand why.
>>
>> After some computations I reach a quite complex expression :
>>
>> [image: Capture d’écran 2020-07-26 à 22.49.18.png]
>>
>>
>>
>> From that I run the following code :
>>
>> import sympy as sp
>>
>> H=-(-CB*Ve*s*(-CA*s - 1/RA)**2/(RB*(CB*s + 1/RB)*(CA*s - (-CA*s - 1/RA)**
>> 2/(CA*s - CB**2*s**2/(CB*s + 1/RB) + CB*s + 1/RA) + 2/RA)*(CA*s - CB**2*s
>> **2/(CB*s + 1/RB) + CB*s + 1/RA)) - CB*Ve*s/(RB*(CB*s + 1/RB)))/(Ve*(CA*s 
>> - CB**2*s**2/(CB*s + 1/RB) + CB*s + 1/RA))
>>
>> H1=H.subs({RB:1e3,CA:1e-6})
>> display(H1)
>> H1.simplify()
>> display(H1)
>>
>> H2 = H.simplify()
>> display(H2)
>> H3=H2.subs({RB:1e3,CA:1e-6})
>> H3.simplify()
>> display(H3)
>>
>>
>> And I obtain what follows. I am surprized that inserting values instead 
>> of some symbols disables sympy simplification. In some more complex cases, 
>> the computation times required for simplification are huge and lead to non 
>> simplified expressions.
>>
>>
>> Any idea why ?
>>
>>
>>   Best regards,
>>
>>     Mike
>>
>> [image: Capture d’écran 2020-07-26 à 22.54.31.png]
>>
>>
>>
>> -- 
>> 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 sy...@googlegroups.com <javascript:>.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/sympy/5622efd3-9718-4d8b-b5cb-373235ab7d42o%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/sympy/5622efd3-9718-4d8b-b5cb-373235ab7d42o%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/2b798f1e-1c3b-4788-a64b-4a9cd8a05febo%40googlegroups.com.

Reply via email to