Discussion:
positive square root
(too old to reply)
paulvonhippel at yahoo
2005-07-14 08:28:30 UTC
Permalink
I work in a world where the square root is always a positive number.
But Mathematica allows for the possibility of negative square roots.
Two questions arise:

(1) Is there a way to tell Mathematica that I'm only interested in
positive square roots?

(2) My current solution is to use, e.g., Abs[Sqrt[z]]. But when
Mathematica echoes this, it puts the Abs function *under* the radical,
so it looks like Sqrt[Abs[z]]. Is this a bug in the display?
dh
2005-07-15 07:06:03 UTC
Permalink
Hi Paul,
Mathematica is correct. You can convince yourselve by considering that
any number r may be written in exponential form:
r= a Exp[-I b]
where a (a>=0) is the absolute value of the number and b (real) its
argument. Taking the square root gives (neglecting multiplicity)
Sqrt[a] Exp[-I b/2]
Taking the absolute value, the exponential disappears. Sqrt[a] is
positive by definition and we are left with:
Sqrt[a]
Therefore:
Abs[Sqrt[r]] == Sqrt[a] == Sqrt[Abs[r]]

sincerely, Daniel
Post by paulvonhippel at yahoo
I work in a world where the square root is always a positive number.
But Mathematica allows for the possibility of negative square roots.
(1) Is there a way to tell Mathematica that I'm only interested in
positive square roots?
(2) My current solution is to use, e.g., Abs[Sqrt[z]]. But when
Mathematica echoes this, it puts the Abs function *under* the radical,
so it looks like Sqrt[Abs[z]]. Is this a bug in the display?
Jens-Peer Kuska
2005-07-15 07:07:34 UTC
Permalink
Hi,

*you* live in a "world where the square root is
always a positive number" ?
and you can't escape ? And what is Sqrt[-1] in
your world ?
For real positive arguments Mathematica will
compute real positve
square roots, just say Simplify[] and
FullSimplify[] that your arguments
are real and positive ?

Regards
Jens

"paulvonhippel at yahoo" <***@yahoo.com>
schrieb im Newsbeitrag news:db57ne$4no$***@smc.vnet.net...
|I work in a world where the square root is always
a positive number.
| But Mathematica allows for the possibility of
negative square roots.
| Two questions arise:
|
| (1) Is there a way to tell Mathematica that I'm
only interested in
| positive square roots?
|
| (2) My current solution is to use, e.g.,
Abs[Sqrt[z]]. But when
| Mathematica echoes this, it puts the Abs
function *under* the radical,
| so it looks like Sqrt[Abs[z]]. Is this a bug in
the display?
|
Jose Luis Gomez
2005-07-15 07:11:28 UTC
Permalink
Hi Paul
Post by paulvonhippel at yahoo
(2) My current solution is to use, e.g., Abs[Sqrt[z]]. But when
Mathematica echoes this, it puts the Abs function *under* the radical,
so it looks like Sqrt[Abs[z]]. Is this a bug in the display?
This is NOT a bug in the display, it is an evaluation. If you write 2+2,
Mathematica will evaluate that to 4, in the same way, if you write
Abs[Sqrt[z]], Mathematica will evaluate it to Sqrt[Abs[z]] (they are in fact
the same for complex numbers). Mathematica evaluates your input, and
sometimes those "evaluations" are, well, somehow silly for a human. For
example, if you write b+a, Mathematica will evaluate that to a+b (just
writing the a before the b).
Post by paulvonhippel at yahoo
(1) Is there a way to tell Mathematica that I'm only interested in
positive square roots?
Actually, Mathematica assumes in some of the commands that you only want the
positive root, for example, if you Plot[Sqrt[x],{x,0,4}] Mathematica plots
only the positive root. So, in which command do you have the problem? Please
be more specific

Finally there is a library that must be used very very very carefully. That
library is RealOnly (you can check it in the AddOns part of the help)
Needs["Miscellaneous`RealOnly`"]
That library could be interesting for you, but it can create problems with
the internal work of other commands that seem not related, like plots or
integrals.

Bye!

Jose Luis
http://homepage.cem.itesm.mx/lgomez/


-----Mensaje original-----
De: paulvonhippel at yahoo [mailto:***@yahoo.com]
Enviado el: Jueves, 14 de Julio de 2005 01:49 a.m.
Para: ***@smc.vnet.net
Asunto: positive square root

I work in a world where the square root is always a positive number.
But Mathematica allows for the possibility of negative square roots.
Two questions arise:

(1) Is there a way to tell Mathematica that I'm only interested in
positive square roots?

(2) My current solution is to use, e.g., Abs[Sqrt[z]]. But when
Mathematica echoes this, it puts the Abs function *under* the radical,
so it looks like Sqrt[Abs[z]]. Is this a bug in the display?
Peter Pein
2005-07-15 07:12:59 UTC
Permalink
Post by paulvonhippel at yahoo
I work in a world where the square root is always a positive number.
But Mathematica allows for the possibility of negative square roots.
(1) Is there a way to tell Mathematica that I'm only interested in
positive square roots?
(2) My current solution is to use, e.g., Abs[Sqrt[z]]. But when
Mathematica echoes this, it puts the Abs function *under* the radical,
so it looks like Sqrt[Abs[z]]. Is this a bug in the display?
Hi Paul,

I don't think so. It is just in general easier, to evaluate Sqrt[Abs[z]]
than Abs[Sqrt[z]]:

In[1]:=
Assuming[(x | y) \[Element] Reals,
FullSimplify[
{Abs[ComplexExpand[Sqrt[x + I*y]]],(*sqrt first*)
ComplexExpand[Sqrt[Abs[x + I*y]]]}]](*abs first*)
Out[1]=
{(x^2 + y^2)^(1/4)*
Abs[Cos[(1/2)*ArcTan[x, y]] + I*Sin[(1/2)*ArcTan[x, y]]],
x^2 + y^2)^(1/4)}

These are of course equivalent:

In[2]:=
SameQ @@ Simplify[ComplexExpand[%]]
Out[2]=
True
--
Peter Pein
Berlin
http://people.freenet.de/Peter_Berlin/
Loading...