Taking the square root of the square of a number
Variable set to a real value
I'm wondering why these examples
a = -4.3;
Sqrt@a²
Sqrt@(a^2)
Sqrt[a^2]
Sqrt[a²]
each return
4.3
the FullForm
of which is
%//FullForm
4.3`
yet
Sqrt@a^2
returns the complex number,
-4.3 + 0. I
the FullForm of which is
%//FullForm
Complex[-4.299999999999999
,0.
]
Why is the last case output as a complex number (with a slightly different real component)?
With an unbound variable
ClearAll[b]
Sqrt@b²
Sqrt@(b^2)
Sqrt[b^2]
Sqrt[b²]
each of the above returns
the FullForm
of which is
Power[Power[b,2],Rational[1,2]]
yet
Sqrt@b^2
returns
b
the FullForm
of which is
%//FullForm
b
Why is the last case treated differently?