4
$\begingroup$

Let's say I want to compute a quantity like $e^{i \pi \vert \vec a \vert}$, and for a certain vector a = {a1,a2,a3} I assume it has length 1, so the quatity would be -1. My minimal example in Mathematica looks like

a = {a1, a2, a3};
Assuming[{a1^2 + a2^2 + a3^2 == 1}, 
ComplexExpand[Exp[I * Pi * Norm[a]]]]

which evaluates to $\cos(\sqrt{a_1^2+a_2^2+a_3^2} \pi) + i \sin(\sqrt{a_1^2+a_2^2+a_3^2} \pi)$ instead of $1$. What am I doing wrong so that Assuming[...] does not work as intentioned?

$\endgroup$

2 Answers 2

8
$\begingroup$

Assuming works by adding conditions to $Assumptions. Some functions make use of $Assumptions and some do not. Generally, it is explicitly mentioned in the documentation, if the function does apply $Assumptions; such functions usually have an Assumptions option. Sometimes functions with the Assumptions options results in a more careful use of the conditions in the option setting than when setting $Assumptions to them (for example, Integrate).

That said, ComplexExpand does not make use of $Assumptions. Neither does ordinary evaluation of expressions. A common way to apply $Assumptions to an expression is to use Simplify.

aa = {a1, a2, a3};
Assuming[{a1^2 + a2^2 + a3^2 == 1}, 
 Simplify@ComplexExpand[Exp[I*Pi*Norm[aa]]]]

(* -1 *)
$\endgroup$
5
$\begingroup$
a = {a1, a2, a3};

Assuming[{a1^2 + a2^2 + a3^2 == 1}, 
 ComplexExpand[Exp[I*Pi*Norm[a]]] // FullSimplify]

FullSimplify[ComplexExpand[Exp[I*Pi*Norm[a]]], 
 Assumptions -> {a1^2 + a2^2 + a3^2 == 1}]

-1
-1
$\endgroup$
1
  • $\begingroup$ You don't need Assumptions -> . The second argument of FullSimplify are the assumptions. $\endgroup$ Commented Feb 9 at 10:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.