This is documentation for Mathematica 5, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.1)

Documentation / Mathematica / The Mathematica Book / A Practical Introduction to Mathematica / Algebraic Calculations /

1.4.6 Advanced Topic: Simplifying with Assumptions

Simplifying with assumptions.

Mathematica does not automatically simplify this, since it is only true for some values of x.

In[1]:= Simplify[Sqrt[x^2]]


is equal to for , but not otherwise.

In[2]:= {Sqrt[4^2], Sqrt[(-4)^2]}


This tells Simplify to make the assumption x > 0, so that simplification can proceed.

In[3]:= Simplify[Sqrt[x^2], x > 0]


No automatic simplification can be done on this expression.

In[4]:= 2 a + 2 Sqrt[a - Sqrt[-b]] Sqrt[a + Sqrt[-b]]


If and are assumed to be positive, the expression can however be simplified.

In[5]:= Simplify[%, a > 0 && b > 0]


Here is a simple example involving trigonometric functions.

In[6]:= Simplify[ArcSin[Sin[x]], -Pi/2 < x < Pi/2]


Some domains used in assumptions.

This simplifies assuming that is a real number.

In[7]:= Simplify[Sqrt[x^2], Element[x, Reals]]


This simplifies the sine assuming that is an integer.

In[8]:= Simplify[Sin[x + 2 n Pi], Element[n, Integers]]


With the assumptions given, Fermat's Little Theorem can be used.

In[9]:= Simplify[Mod[a^p, p], Element[a, Integers]
&& Element[p, Primes]]


This uses the fact that , but not , is real when is real.

In[10]:= Simplify[Re[{Sin[x], ArcSin[x]}], Element[x, Reals]]