Expand does not expands?
Hello, I got to GiNaC only recently, and I have some troubles with the expand() function. I would expect following code -------- #include <ginac/ginac.h> using namespace GiNaC; symbol x("x"), y("y"); ex laplace_in_oblates(const ex& potential) { ex x_part=diff((x*x-1)*diff(potential,x), x); ex y_part=diff((1-y*y)*diff(potential,y), y); return normal(x_part+y_part); } int main() { ex R=sqrt(x*x+y*y-1); ex tmp=expand(pow(R, 5)*laplace_in_oblates(1/R)); cout << tmp<<" = "<<tmp.normal() << endl; return 0; } --------- to yield 0 = 0, but it gives 3*(-1+x^2+y^2)*y^2-3*x^2+3*x^4-3*(-1+x^2+y^2)*x^2-3*y^4+3*y^2 = 0 I would say that the polynomial on the left side is not expanded, in spite of the fact that it should be result of an expand. Anyone give me a hint what I am doing/expecting wrong? (tried on GiNaC version 0.6.4 on RedHat Linux 6.1 and GiNaC 0.8.3 on RH 7.1) Thanks Tomas Zellerin - To UNSUBSCRIBE, email to ginac-list@ginac.de with a subject of "unsubscribe".
Hi! On Mon, May 28, 2001 at 01:51:51PM +0200, zellerin@winbase.software602.cz wrote:
3*(-1+x^2+y^2)*y^2-3*x^2+3*x^4-3*(-1+x^2+y^2)*x^2-3*y^4+3*y^2 = 0
I would say that the polynomial on the left side is not expanded, in spite of the fact that it should be result of an expand. Anyone give me a hint what I am doing/expecting wrong?
You are calling normal() after expand() and normal() is not guaranteed to return an expanded numerator. Specifically, it is not expanded because there's a square root in it ((x^2+y^2-1)^1/2) that is treated as a single object by normal(). You have to call expand() after normal() if you want an expanded result. Also, the operation of normal should not depend on whether or not its input expression is expanded (it may only affect its runtime and the expanded-ness of the result). Bye, Christian -- / Coding on PowerPC and proud of it \/ http://www.uni-mainz.de/~bauec002/ - To UNSUBSCRIBE, email to ginac-list@ginac.de with a subject of "unsubscribe".
participants (2)
-
Christian Bauer
-
zellerinï¼ winbase.software602.cz