Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Can someone shed some light on why

Assuming[{x ∈ Reals}, x (Sign[x]^2 - 1)] // FullSimplify

returns

x (-1 + Sign[x]^2)

instead of zero please?
I know one can not expect FullSimplify to perform miracles but this example does seem pretty obvious.

share|improve this question
    
It returns zero for me. Version 9.0. –  Pickett Nov 8 '13 at 12:36
    
FullSimplify[x (Sign[x]^2 - 1), Assumptions -> {x \[Element] Reals}] gives 0 on version 9.0.1 –  cormullion Nov 8 '13 at 12:37
    
ver@cormullion, I have a 64 bit 9.0.1.0 student version on a 64 bit Win 8 machine and get what I posted. –  Freakalien Nov 8 '13 at 12:50
    
Sorry @cormuullion, I posted my comment too quickly. Yes I also get zero for your modified example using Assumptions, but the question still remains for my original example. –  Freakalien Nov 8 '13 at 12:54
    
@Anon, you get zero? Are you using a student version? –  Freakalien Nov 8 '13 at 12:55
show 1 more comment

2 Answers 2

up vote 6 down vote accepted

Your example evaluates

Assuming[{x ∈ Reals}, x (Sign[x]^2 - 1)]

BEFORE simplifying.

The correct way to inform your assumptions to FullSimplify[] is:

FullSimplify[x (Sign[x]^2 - 1), Assumptions -> {x ∈ Reals}] 

Which returns zero.

Or

Assuming[{x ∈ Reals}, FullSimplify[x (Sign[x]^2 - 1)]]
share|improve this answer
2  
Yep, makes sense. Cheers... –  Freakalien Nov 8 '13 at 13:25
add comment

1. The first reason is that Sign[0] yields 0, so even assuming x ∈ Reals this expression:
Sign[x]^2 - 1 cannot be evaluated to 0.

2. The next problem is that Assuming[{x ∈ Reals}, x (Sign[x]^2 - 1)] is evaluated first, then the assumption imposed doesn't affect the simplification procedure since FullSimplify being outside Assuming doesn't know anything about x, thus the final result is correct.

Ad 1. In general Sign is a complex function, for a complex number $ z\neq0\;$ it is equal to z/Abs[z], e.g. see its graphs of the real and imaginary parts:

GraphicsRow[ Table[ Plot3D[ f @ Sign[x + I y], {x, -3, 3}, {y, -3, 3}, 
                            ColorFunction -> "DeepSeaColors",], {f, {Re, Im}}]]

enter image description here

Ad.2

One can impose global assumptions for a Mathematica session, e.g.

$Assumptions = z ∈ Reals;

then one can do as it was assumed in the question:

z (Sign[z]^2 - 1) // FullSimplify
0

On the other hand you can use assumption restricted to FullSimplify only:

FullSimplify[ x (Sign[x]^2 - 1), x ∈ Reals]
0

For more detailed discussion see e.g. this question How to specify assumptions before evaluation?.

share|improve this answer
    
I don't have the points to up vote your answer so thanks. –  Freakalien Nov 8 '13 at 13:27
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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