[GiNaC-list] Simplification in GiNaC
Vladimir V. Kisil
kisilv at maths.leeds.ac.uk
Sat Jan 7 11:53:12 CET 2017
Hi,
Avoiding discussion on correct transformations towards simpler
expressions in general, here is an advise on your particular example.
You can use susb method with wildcards to make manual transformation
pow(X,1/2)*pow(Y,1/2) -> pow(X*Y,1/2)
Also, with square roots it will be better to use possymbol instead of
realsymbol whenever possible. This even can make the desired
transformation automatically through the expand method. (the desired
answer is not correct for arbitrary reals, indeed)
Best wishes,
Vladimir
--
Vladimir V. Kisil http://www.maths.leeds.ac.uk/~kisilv/
Book: Geometry of Mobius Transformations http://goo.gl/EaG2Vu
Software: Geometry of cycles http://moebinv.sourceforge.net/
>>>>> On Fri, 6 Jan 2017 21:52:32 +0500, abpetrov <abpetrov at ufacom.ru> said:
ABP> Hello, I recently wrote a simple program to learn some
ABP> calculations with GiNaC. This works, But I got some expression
ABP> which automatically don't become simple. The question is: What
ABP> is the simplest way to get the expected answer - Ax here?
ABP> Best regards Petrov A.B.
ABP> --------------------------------------------------------------------
ABP> Output for program:
ABP> Starting: ./test2 sqrt(m*x^2*A)*sqrt(m^(-1)*A) *** Exited
ABP> normally ***
ABP> ------------------------------------------------------------------
ABP> Program:
ABP> #include <iostream> using namespace std;
ABP> #include<ginac/ginac.h> using namespace GiNaC;
ABP> void calc_example(){ realsymbol A("A"),m("m"),x("x"); ex e =
ABP> sqrt(A*m*pow(x,2))*sqrt(A/m); cout << e << endl; }
ABP> int main(int argc, char** argv) { calc_example(); return 0; }
ABP> _______________________________________________ GiNaC-list
ABP> mailing list GiNaC-list at ginac.de
ABP> https://www.cebix.net/mailman/listinfo/ginac-list
More information about the GiNaC-list
mailing list