2
$\begingroup$

Here is what I have used for this.
From this link, Why do I get empty graph when adding 'Abs' function? I know that I can remove Abs with ComplexExpand
Input

ComplexExpand[Sqrt[1 - Abs[x]^2]]

Output

((1 - x^2)^2)^(1/4) Cos[1/2 Arg[1 - Abs[x]^2]] + 
 I ((1 - x^2)^2)^(1/4) Sin[1/2 Arg[1 - Abs[x]^2]]

However, it works just fine when I use Plus in the Sqrt.
Input

ComplexExpand[Sqrt[1 + Abs[x]^2]]

Output

Sqrt[1 + x^2]

Is there anyone who can explain this?

$\endgroup$
3
  • $\begingroup$ Maybe you can try setting the option TargetFunctions->{Re, Im} to ComplexExpand? $\endgroup$
    – QuantumDot
    Jul 26, 2020 at 5:44
  • 1
    $\begingroup$ Documentation says ComplexExpand assumes all variables are real. Since your example doesn't work, perhaps they missed a case. Or you can use Simplify[Sqrt[1+ Abs[x]^2],Element[x,Reals]] which works with both + and - and get on with the work you need to do. $\endgroup$
    – Bill
    Jul 26, 2020 at 6:02
  • $\begingroup$ @QuantumDot, your method is not working $\endgroup$
    – kile
    Jul 26, 2020 at 6:16

1 Answer 1

1
$\begingroup$

Maybe adding Simplify gives you what you want.

ComplexExpand[Sqrt[1 - Abs[x]^2]] // Simplify
(*Piecewise[{{I*((x^2 - 1)^2)^(1/4), Abs[x] > 1}}, ((x^2 - 1)^2)^(1/4)]*)

or

$Assumptions = -1 < x < 1

ComplexExpand[Sqrt[1 - Abs[x]^2]] // Simplify
(*Sqrt[1 - x^2]*)

The plus case is different because the value inside the Sqrt is always positive. It is generally a good idea to add Simplify to any result ComplexExpand returns.

$\endgroup$
1
  • $\begingroup$ I think there is no need to add ComplexExpand. You pan get the same result with only Simplify used here $\endgroup$
    – kile
    Jul 27, 2020 at 4:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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