Hi, I am wondering how one can get GiNaC to expand the expression sqrt(x*x) to x (where symbol x("x")), under the assumption than x is real. Does GiNaC have a function to perform such an expansion? I looked though the reference PDF file but could not find anything analogous to Mathematica's PowerExpand. When one can be sure that complex numbers are not involved it is often quite a nice simplification. Regards, Freddie.
Hi, Freddie Witherden wrote:
I am wondering how one can get GiNaC to expand the expression sqrt(x*x) to x (where symbol x("x")), under the assumption than x is real. Does GiNaC have a function to perform such an expansion? I looked though the reference PDF file but could not find anything analogous to Mathematica's PowerExpand.
When one can be sure that complex numbers are not involved it is often quite a nice simplification.
Think about x<0. Bye -richy. -- Richard B. Kreckel <http://www.ginac.de/~kreckel/>
Hi! Freddie Witherden wrote:
Richard B. Kreckel wrote:
Think about x<0.
Ah, I forgot to mention where x>0 (positive real values of x).
Look up 'possymbol' in the user manual.
Long day :)
Short knight. :( -richy. -- Richard B. Kreckel <http://www.ginac.de/~kreckel/>
Hi, On 13 Dec 2008, at 22:12, Richard B. Kreckel wrote:
Look up 'possymbol' in the user manual.
That did the trick, thanks. However, it doesn't seem to reduce the case of possymbol x("x"), y("y"); ex expr = sqrt(x*x*y*y) or sqrt(pow(x*y,2)); Although both are
0 and real it is not reduced to x*y. I have played around with some of the factorization functions to no avail. Does GiNaC support this kind of simplification? Could very well just be me missing something in the reference (Doxygen) docs.
(Although strictly speaking I enquired about sqrt(x*x); sqrt(y*y*x*x) where x and y are real > 0, it is something of a natural extension.) Regards, Freddie.
participants (2)
-
Freddie Witherden
-
Richard B. Kreckel