Hi, I've just started using GiNaC (and very nice it is too!), however I have some strange behavior with an expression not being simplified. One output of a linear equation solver is the expression: (C_2 *s ^ 2 *L_2 *V_1 + C_2 *L_1 *C_1 *s ^ 4 *L_2 *V_1 + L_1 *C_1 *s ^ 2 *V_1 + V_1 )*(1 +L_1*C_1*s^2+C_2*L_1*s^2+C_2*L_1*C_1*s^4*L_2+C_2*s^2*L_2)^(-1)*V_1^(-1) What is happening is that the V_1 terms in the first bracket are not being factorised, and therefore no cancellation with the final (V_1)^(-1) term is occuring. All my symbols are created with a SymbolFactory pattern, so I can be sure each V_1 is the same object. Can anyone suggest why GiNaC isn't simplifying this to cancel the V_1 terms? Regards, James.
Hi, James Jackson wrote:
I've just started using GiNaC (and very nice it is too!), however I have some strange behavior with an expression not being simplified. One output of a linear equation solver is the expression:
(C_2*s^2*L_2*V_1+C_2*L_1*C_1*s^4*L_2*V_1+L_1*C_1*s^2*V_1+V_1)*(1+L_1*C_1*s^2+C_2*L_1*s^2+C_2*L_1*C_1*s^4*L_2+C_2*s^2*L_2)^(-1)*V_1^(-1)
What is happening is that the V_1 terms in the first bracket are not being factorised, and therefore no cancellation with the final (V_1)^(-1) term is occuring. All my symbols are created with a SymbolFactory pattern, so I can be sure each V_1 is the same object.
Can anyone suggest why GiNaC isn't simplifying this to cancel the V_1 terms?
The linear solvers don't cancel common factors in numerator and denominator. You have to explicitly call normal() on the result in order to do that. Bye -richy. -- Richard B. Kreckel <http://www.ginac.de/~kreckel/>
Hi, Ah excellent, normal() has performed the cancellation. Thanks! James. On 16 Feb 2009, at 17:17, Richard B. Kreckel wrote:
Hi,
James Jackson wrote:
I've just started using GiNaC (and very nice it is too!), however I have some strange behavior with an expression not being simplified. One output of a linear equation solver is the expression: (C_2 *s ^ 2 *L_2 *V_1 + C_2 *L_1 *C_1 *s ^ 4 *L_2 *V_1 + L_1 *C_1 *s ^ 2 *V_1 + V_1 )*(1 + L_1 *C_1*s^2+C_2*L_1*s^2+C_2*L_1*C_1*s^4*L_2+C_2*s^2*L_2)^(-1)*V_1^(-1) What is happening is that the V_1 terms in the first bracket are not being factorised, and therefore no cancellation with the final (V_1)^(-1) term is occuring. All my symbols are created with a SymbolFactory pattern, so I can be sure each V_1 is the same object. Can anyone suggest why GiNaC isn't simplifying this to cancel the V_1 terms?
The linear solvers don't cancel common factors in numerator and denominator. You have to explicitly call normal() on the result in order to do that.
Bye -richy. -- Richard B. Kreckel <http://www.ginac.de/~kreckel/> _______________________________________________ GiNaC-list mailing list GiNaC-list@ginac.de https://www.cebix.net/mailman/listinfo/ginac-list
Hello, On Mon, Feb 16, 2009 at 04:05:33PM +0000, James Jackson wrote:
(C_2*s^2*L_2*V_1+C_2*L_1*C_1*s^4*L_2*V_1+L_1*C_1*s^2*V_1+V_1)*(1 +L_1*C_1*s^2+C_2*L_1*s^2+C_2*L_1*C_1*s^4*L_2+C_2*s^2*L_2)^(-1)*V_1^(-1)
What is happening is that the V_1 terms in the first bracket are not being factorised, and therefore no cancellation with the final (V_1)^(-1) term is occuring. All my symbols are created with a SymbolFactory pattern, so I can be sure each V_1 is the same object.
Can anyone suggest why GiNaC isn't simplifying this to cancel the V_1 terms?
It's a feature: GiNaC's automatic evaluator does not do any expensive operations (such as computing GCDs, which is necessary to cancel common factors). GiNaC is designed to process quite a large expressions (> 10^7 terms), so anything complicated (i.e. more expensive than O(N^2)) is done only upon user's request. Otherwise it would be difficult even to input the expression, let alone doing anything non-trivial with it (see e.g. http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=407109). Best regards, Alexei
participants (3)
-
Alexei Sheplyakov
-
James Jackson
-
Richard B. Kreckel