Thanks for your answer. I don’t do it « for sport » ;-) My example is a reduced example coming from a practical situation I encountered. Here it is : I developed a small software that solves the voltages and currents of an electronic circuit described by means of a standard format (« netlist »). This file is parsed, equations are solved. In this netlist file, the values of the components are given. I imagined that I could mix symbolic and numerical values in the description of the circuit (for example we want to study de variations of a single component, not of all), and it seems to be a bad idea because mixed expressions seem to be really difficult to handle for Sympy. So I will have to make 100% symbolic treatment and then only replace the values of the components. It was to explore the possibilities for my students : this kind of question will help me giving to them good orientations during classroom work.
Thanks again, Mike Le vendredi 31 juillet 2020 18:21:22 UTC+2, David Bailey a écrit : > > On 31/07/2020 15:59, Mikhael Myara wrote: > > Perhaps my example was not clear enough. I start with a fully symbolic > expression. Then, I try two things : > - ask a simplify on the fully symbolic expression, that works well, > - replace some symbols in the initial expression and then simplify. > > The first step shows that a simplified expression exists, and replacing by > values may not change this fact (it can lead to an even more simplified > expresssion isn'nt it ?). > > I do not understand why Sympy cannot simplify at all the initial > expression when symbols are replaced by values, whereas we know that a > simplified expresssion exists as Sympy itself found it from the fully > symbolic version. > > My guess would be that due to rounding errors, when the floating point > numbers get combined - added or subtracted etc. those rounding errors make > what would be exact matches become inexact. For example A-B+B might be > slightly different from A. Put another way, floating point numbers don't > (quite) obey the laws of arithmetic! > > I would definitely advise that you work with symbols and integers until > you are ready to substitute floating point numbers. > > I can't quite see why you would want to substitute and then simplify. > > David > -- 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 [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/9a67a3dd-d724-4009-8cb9-d5fc700f195ao%40googlegroups.com.
