[GiNaC-devel] Some more evaluation rules for abs()

Alexei Sheplyakov alexei.sheplyakov at gmail.com
Wed Jul 31 09:30:26 CEST 2013


Hello,

On Tue, Jul 30, 2013 at 07:25:15PM +0100, Vladimir V. Kisil wrote:
>   I have added some more evaluation rules for abs(). They evaluate
>  absolute values of powers and exponents. Simple checks
>  are added as well. The effect is like this:
> 
>   realsymbol a("a"), b("b"), x("x"), y("y");
> 
>   cout << abs(exp(x+I*y)).eval() << endl;
>   // before: -> abs(exp(x+I*y))
>   // now:    -> exp(x)

No objections here.

>   cout << abs(pow(x+I*y,a+I*b)).eval() << endl;
>   // before: -> abs((x+I*y)^(I*b+a))
>   // now:    -> abs(x+I*y)^a

I feel so stupid but

Z^A = exp(A log(Z)) = exp((Re(A) + I Im(A)) (ln|Z| + I arg(Z))) =
exp(Re(A) ln|Z| - Im(A) arg(Z) + I (Im(A) ln|Z| + Re(A) arg(Z))) =
exp(Re(A) ln|Z| - Im(A) arg(Z)) exp(I(Im(A) ln|Z| + Re(A) arg(Z)))

Hence |Z^A| = exp(Re(A) ln|Z| - Im(A) arg(Z)) = |Z|^Re(A) exp(-Im(A) arg(Z))

In particular |(-1)^I| = | exp(I (I Pi)) | = |exp(-Pi)| = exp(-Pi)

What I'm doing wrong?

Best regards,
	Alexei



More information about the GiNaC-devel mailing list