Simplifying with Assumptions

Simplifying with assumptions.

The Wolfram Language does not automatically simplify this, since it is only true for some values of x:

Simplify[Sqrt[x^2]]

(Sqrt[(x^2)]) is equal to x for x≥0, but not otherwise:

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

This tells (RefLink[Simplify, paclet:ref/Simplify]) to make the assumption x>0, so that simplification can proceed:

Simplify[Sqrt[x^2],x>0]

No automatic simplification can be done on this expression:

2 a+2 Sqrt[a-Sqrt[-b]] Sqrt[a+Sqrt[-b]]

If a and b are assumed to be positive, the expression can however be simplified:

Simplify[%,a>0&&b>0]

Here is a simple example involving trigonometric functions:

Simplify[ArcSin[Sin[x]],-Pi/2<x<Pi/2]

Some domains used in assumptions.

This simplifies (Sqrt[(x^2)]) assuming that x is a real number:

Simplify[Sqrt[x^2],Element[x,Reals]]

This simplifies the sine assuming that n is an integer:

Simplify[Sin[x+2 n Pi],Element[n,Integers]]

With the assumptions given, Fermat's little theorem can be used:

Simplify[Mod[a^p,p],Element[a,Integers]&&Element[p,Primes]]

This uses the fact that sin(x), but not arcsin(x), is real when x is real:

Simplify[Re[{Sin[x],ArcSin[x]}],Element[x,Reals]]