Why does this:
Simplify[Abs[x + I], Element[x, Reals]]
give me
Abs[x + i]
Is there a way to force Mathematica to give me the following answer?
$\sqrt{x^2+1}$
Why does this:
Simplify[Abs[x + I], Element[x, Reals]]
give me
Abs[x + i]
Is there a way to force Mathematica to give me the following answer?
$\sqrt{x^2+1}$
If you steal the wizard's explanation an apply it to your case
cf[e_] := 100 Count[e, _Abs, {0, Infinity}] + LeafCount[e]
Then
FullSimplify[Abs[x + I], x \[Element] Reals, ComplexityFunction -> cf]
(* Sqrt[x^2+1] *)
but once again I just copied and vaguely adapted the link provided by kuba
Count[..,I,..]? may be more general if it works (sorry cant try frm here)
– george2079
Mar 29 '14 at 15:17
cf[e_] := 100 Count[e, _Complex, {0, Infinity}] + LeafCount[e] works too
– chris
Mar 29 '14 at 15:33
ComplexityFunction in the find button on the left above in the menu bar...
– chris
Mar 29 '14 at 20:03
How about using ComplexExpand
ComplexExpand[Abs[x + I]]
Gives:
Sqrt[1 + x^2]
ComplexityFunctionisLeafCountwhich gives6forAbsform and9forSqrt, that's why it is left. – Kuba Mar 29 '14 at 08:55