2

I want to prevent Mathematica from using the identity $e^{2i \pi} = 1$ because at a later step I will evaluating something like $\left(e^{2i \pi}\right)^\alpha$ for some non integer $\alpha$. I wish for it to return $e^{2i\pi\alpha}$ instead of $1$. How do I do that?

In the actual computation, such expression appears multiple times in a bigger expression and I would appreciate a solution that I can apply universally during the evaluation of a cell or file instead having to do it multiple times within an expression.

MWE:

((f[z]/f[zb])^(\[Alpha]/2) + (f[zb]/f[z])^(\[Alpha]/2)) /. {f[z] -> E^(2 \[Pi] I) f[zb]}

returns 2 while I would like it to return $2 \cos\left(\pi \alpha\right)$.

nGlacTOwnS
  • 123
  • 6
  • This might require an MWE, minimal code example. You could try Inactivate[expr, Power] at an appropriate juncture, perhaps using Hold to prevent evaluation. – Michael E2 Jul 03 '19 at 03:34
  • 1
    does the following work in your case: Block[{Pi = pi}, (E^(2 I Pi ))^w] /. Power[Power[E, a_], b_] :> Power[E, a b] /. pi -> Pi? – kglr Jul 03 '19 at 03:56
  • 1
    @kglr Thanks! It does work for the MWE but I am trying to make it work for my problem. – nGlacTOwnS Jul 03 '19 at 04:24

3 Answers3

2
ClearAll[foo]
foo = Function[, Block[{Pi = pi}, PowerExpand @ #] /. pi -> Pi , HoldAll];

foo@(((f[z]/f[zb])^(α/2) + (f[zb]/f[z])^(α/2)) /. {f[z] -> E^(2 π I) f[zb]})

E^(-I π α) + E^(I π α)

kglr
  • 394,356
  • 18
  • 477
  • 896
1

I'd like to draw attention to the fact that the transformation you're trying to do is most likely not mathematically correct. Compare:

FullSimplify[Exp[2 pi ]^a, Assumptions -> a > 0 && pi > 0]
FullSimplify[Exp[2 pi I]^a, Assumptions -> a > 0 && pi > 0]

E^(2 a pi)

(E^(2 I pi))^a

As you can see, Mathematica refuses to put the a into the exponent in the second line. This is because the transformation (a^b)^c -> a^(b c) only holds for real numbers. In fact, you can easily test that Exp[2 I Pi]^a is different from Exp[2 I Pi a] by substituting numerical values for a.

Sjoerd Smit
  • 23,370
  • 46
  • 75
  • Raising complex numbers to any power is a multivalued function. The transformation is mathematically correct, but you have to take into account that you miss all other values for n!=0 in there (e^(i b))^c -> e^(i(b + 2 Pi n)c). – swish Jul 03 '19 at 10:08
  • @swish Point taken, but I think that most people will not think of power as a multivalued function. Hence my warning, because many people simply aren't aware of this issue. See, e.g., https://qr.ae/TW1bE3 – Sjoerd Smit Jul 03 '19 at 10:18
  • Indeed, I am totally aware of multivalued nature of the function. That's why I want to hold evaluations. But thanks for the warning for a general reader of this question. – nGlacTOwnS Jul 03 '19 at 13:11
1

Maybe try to use this function to raise complex numbers to any power:

ComplexPower[x_, z_, n_: 1] := Module[{r, a},
  {r, a} = AbsArg[x];
  ConditionalExpression[r^z E^(I (a + 2 Pi C[n]) z), C[n] \[Element] Integers]
]

It gives you more control over returned multiple values after.

You can get your desired result substituting correct choices for arbitrary integers in the final expression:

ComplexPower[1, a/2] + ComplexPower[1, a/2, 2] /. {C[1] -> -1, C[2] -> 1} // ComplexExpand

(*2 Cos[Pi a]*)
swish
  • 7,881
  • 26
  • 48