 |  |
1.4.6 Advanced Topic: Simplifying with Assumptions
| Simplify[expr, assum] | simplify expr 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]]
|
Out[1]=
|
|
| This tells Simplify to make the assumption x > 0, so that simplification can proceed. | |
In[3]:=
Simplify[Sqrt[x^2], x > 0]
|
Out[3]=
|
|
| No automatic simplification can be done on this expression. | |
In[4]:=
2 a + 2 Sqrt[a - Sqrt[-b]] Sqrt[a + Sqrt[-b]]
|
Out[4]=
|
|
If and are assumed to be positive, the expression can however be simplified. | |
In[5]:=
Simplify[%, a > 0 && b > 0]
|
Out[5]=
|
|
| Here is a simple example involving trigonometric functions. | |
In[6]:=
Simplify[ArcSin[Sin[x]], -Pi/2 < x < Pi/2]
|
Out[6]=
|
|
| Element[x, dom] | state that x is an element of the domain dom | Element[{ , , ... }, dom] | state that all the are elements of the domain dom | | Reals | real numbers | | Integers | integers | | Primes | prime numbers |
Some domains used in assumptions. This simplifies assuming that is a real number. | |
In[7]:=
Simplify[Sqrt[x^2], Element[x, Reals]]
|
Out[7]=
|
|
This simplifies the sine assuming that is an integer. | |
In[8]:=
Simplify[Sin[x + 2 n Pi], Element[n, Integers]]
|
Out[8]=
|
|
| With the assumptions given, Fermat's Little Theorem can be used. | |
In[9]:=
Simplify[Mod[a^p, p], Element[a, Integers] && Element[p, Primes]]
|
Out[9]=
|
|
|
|
|