Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Square root of a square

436 views
Skip to first unread message

Mariano Suárez-Alvarez

unread,
Feb 27, 2010, 3:13:20 AM2/27/10
to
Hi all,

Mathematica evaluates FullSimplify[Sqrt[x^2]] to Sqrt[x^2], while it
tells me that FullSimplify[Sqrt[x^2] == x] is True.
Are these the expected answers?

-- m

Adam Strzebonski

unread,
Feb 28, 2010, 4:52:26 AM2/28/10
to
Andrzej Kozlowski wrote:
> The second certainly not the answer I would expect, in fact this looks to me like a serious (perhaps even "shocking") bug. It certainly contradicts this answer:
>
> FindInstance[Sqrt[x^2] != x, x]
>
> {{x -> -(109/5) + (11*I)/5}}
>
>
> Andrzej Kozlowski
>

It is a bug in V7.0. The function used by FullSimplify to
simplify equations involving holonomic functions does not
handle branch cuts correctly. It can be disabled with

In[1]:= Unprotect[Holonomic`HolonomicFullSimplify];
Clear[Holonomic`HolonomicFullSimplify];

In[2]:= FullSimplify[Sqrt[x^2] == x]

2
Out[2]= Sqrt[x ] == x

Best Regards,

Adam Strzebonski
Wolfram Research

Leonid Shifrin

unread,
Feb 28, 2010, 5:00:51 AM2/28/10
to
Hi Mariano,

The first result (that Sqrt[x^2] does not simplify further without
additional assumptions) was expected. However, the second result (that
Mathematica simplifies Sqrt[x^2] == x to True) looks like a bug to me.

Regards,
Leonid

Bob Hanlon

unread,
Feb 28, 2010, 5:01:34 AM2/28/10
to

FullSimplify[Sqrt[x^2] == x]

True

This is wrong since for real x, Sqrt is always non-negative and x could be =
negative.

x = -3;

Sqrt[x^2] == x

False


Bob Hanlon

---- "Mariano Su=C3=A1rez-Alvarez" <mariano.su...@gmail.com> wrote:=


=============

Andrzej Kozlowski

unread,
Feb 28, 2010, 5:02:06 AM2/28/10
to

On 27 Feb 2010, at 09:13, Mariano Su=E1rez-Alvarez wrote:

> Hi all,
>
> Mathematica evaluates FullSimplify[Sqrt[x^2]] to Sqrt[x^2], while it
> tells me that FullSimplify[Sqrt[x^2] == x] is True.
> Are these the expected answers?
>
> -- m
>

The second certainly not the answer I would expect, in fact this looks

Christoph Lhotka

unread,
Mar 1, 2010, 4:44:26 AM3/1/10
to
hi, this is something, which is really needed to be discussed:

1) Simplify[Sqrt[x^2] == x, x \[Element] Reals]
2) Simplify[Sqrt[x^2] == x, x \[Element] Complexes]
3) Simplify[Sqrt[x^2] == x, x < 0]

works fine, while

1) FullSimplify[Sqrt[x^2] == x, x \[Element] Reals]
2) FullSimplify[Sqrt[x^2] == x, x \[Element] Complexes]
3) FullSimplify[Sqrt[x^2] == x, x < 0]

will return a wrong result in the 2nd case.

The problem seems to be only in version 7, not in version 6 or version 5.

chr

> :


Andrzej Kozlowski

unread,
Mar 1, 2010, 4:44:37 AM3/1/10
to
Did you not notice Adam Strzebonski's explanation in this thread?
Quote:

> It is a bug in V7.0. The function used by FullSimplify to
> simplify equations involving holonomic functions does not
> handle branch cuts correctly. It can be disabled with
>
> In[1]:= Unprotect[Holonomic`HolonomicFullSimplify];
> Clear[Holonomic`HolonomicFullSimplify];
>
> In[2]:= FullSimplify[Sqrt[x^2] == x]
>
> 2
> Out[2]= Sqrt[x ] == x
>
> Best Regards,
>
> Adam Strzebonski
> Wolfram Research

Andrzej Kozlowski


On 1 Mar 2010, at 09:41, Christoph Lhotka wrote:

> hi, this is something, which is really needed to be discussed:
>
> 1) Simplify[Sqrt[x^2] == x, x \[Element] Reals]
> 2) Simplify[Sqrt[x^2] == x, x \[Element] Complexes]
> 3) Simplify[Sqrt[x^2] == x, x < 0]
>
> works fine, while
>
> 1) FullSimplify[Sqrt[x^2] == x, x \[Element] Reals]
> 2) FullSimplify[Sqrt[x^2] == x, x \[Element] Complexes]
> 3) FullSimplify[Sqrt[x^2] == x, x < 0]
>
> will return a wrong result in the 2nd case.
>

> The problem seems to be only in version 7, not in version 6 or version =


5.
>
> chr
>
>
> Andrzej Kozlowski wrote:
>> On 27 Feb 2010, at 09:13, Mariano Su=E1rez-Alvarez wrote:
>>
>>
>>> Hi all,
>>>
>>> Mathematica evaluates FullSimplify[Sqrt[x^2]] to Sqrt[x^2], while it
>>> tells me that FullSimplify[Sqrt[x^2] == x] is True.
>>> Are these the expected answers?
>>>
>>> -- m
>>>
>>>
>>

>> The second certainly not the answer I would expect, in fact this =
looks to me like a serious (perhaps even "shocking") bug. It certainly =

janj...@gmail.com

unread,
Mar 9, 2010, 6:23:31 AM3/9/10
to
On Feb 28, 10:52 am, Adam Strzebonski <ad...@wolfram.com> wrote:
> Andrzej Kozlowski wrote:
> > On 27 Feb 2010, at 09:13, Mariano Su=E1rez-Alvarez wrote:
>
> >> Hi all,
>
> >> Mathematica evaluates FullSimplify[Sqrt[x^2]] to Sqrt[x^2], while it
> >> tells me that FullSimplify[Sqrt[x^2] == x] is True.
> >> Are these the expected answers?
>
> >> -- m
>
> > The second certainly not the answer I would expect, in fact this looks to me like a serious (perhaps even "shocking") bug. It certainly contradicts this answer:

>
> > FindInstance[Sqrt[x^2] != x, x]
>
> > {{x -> -(109/5) + (11*I)/5}}
>
> > Andrzej Kozlowski
>
> It is a bug in V7.0. The function used by FullSimplify to
> simplify equations involving holonomic functions does not
> handle branch cuts correctly. It can be disabled with
>
> In[1]:= Unprotect[Holonomic`HolonomicFullSimplify];
> Clear[Holonomic`HolonomicFullSimplify];
>
> In[2]:= FullSimplify[Sqrt[x^2] == x]
>
> 2
> Out[2]= Sqrt[x ] == x
>
> Best Regards,
>
> Adam Strzebonski
> Wolfram Research

This type of error seems to be more wide-spread in Mathematica.
The following Mathematica code gives two answers, one of which is
incorrect, even after entering the unprotect and clear commands above:

DSolve[{y'[x] == 2 y[x] (x Sqrt[y[x]] - 1), y[0] == 1}, y[x], x]

{{y[x] -> 1/(-1 + 2 E^x - x)^2}, {y[x] -> 1/(1 + x)^2}}

The error appears for me in all Mathematica versions I could test,
that is 5.2, 6.0 and 7.0. The first solution can only be imagined to
be correct if you assume Sqrt[x^2] ==x.

Regards,

Jan Jitse Venselaar

Andrzej Kozlowski

unread,
Mar 10, 2010, 6:30:03 AM3/10/10
to

I think this is a different issue and may not involve any bug. This looks to me just the "usual" problem with parasite solutions that inevitably appear in functions like Solve when equations involving parameters are involved. I do not think DSolve attempts to verify the correctness of the solutions it returns (just as Solve does not in parametric cases), so there is no alternative to doing it by hand. However, when doing so its certainly a good idea to clear Holonomic`HolonomicFullSimplify, although in this particular case it does not matter.

In[1]:= sols =
DSolve[{Derivative[1][y][x] == 2*y[x]*(x*Sqrt[y[x]] - 1),
y[0] == 1}, y, x];

In[2]:= (FullSimplify[#1, x > 0] & )[
{Derivative[1][y][x] == 2*y[x]*(x*Sqrt[y[x]] - 1), y[0] == 1} /.
sols]

Out[2]= {{False, True}, {True, True}}

Andrzej Kozlowski=

0 new messages