Mathematica normally makes as few assumptions as possible about the objects you ask it to manipulate. This means that the results it gives are as general as possible. But sometimes these results are considerably more complicated than they would be if more assumptions were made.
Refine@expr,assumD refine expr using assumptions Simplify@expr,assumD simplify with assumptions FullSimplify@expr,assumD full simplify with assumptions FunctionExpand@expr,assumD function expand with assumptions Doing operations with assumptions.
Simplify by default does essentially nothing with this expression.
In[1]:= Simplify@1 ê Sqrt@xD - Sqrt@1 ê xDD
Out[1]= - 1 x
+ 1
x
The reason is that its value is quite different for different choices of x.
In[2]:= % ê. x -> 8- 3, - 2, - 1, 1, 2, 3<
Out[2]= :-2 Â 3
, -Â 2 , -2 Â, 0, 0, 0>
With the assumption x > 0, Simplify can immediately reduce the expression to 0.
In[3]:= Simplify@1 ê Sqrt@xD - Sqrt@1 ê xD, x > 0D
Out[3]= 0
Without making assumptions about x and y, nothing can be done.
In[4]:= FunctionExpand@Log@x yDD
Out[4]= Log@x yD
If x and y are both assumed positive, the log can be expanded.
In[5]:= FunctionExpand@Log@x yD, x > 0 && y > 0D
Out[5]= Log@xD + Log@yD
By applying Simplify and FullSimplify with appropriate assumptions to equations and inequalities you can in effect establish a vast range of theorems.
Without making assumptions about x the truth or falsity of this equation cannot be determined.
In[6]:= Simplify@Abs@xD == xD
Out[6]= x ã Abs@xD
Now Simplify can prove that the equation is true.
Now Simplify can prove that the equation is true.
In[7]:= Simplify@Abs@xD == x, x > 0D
Out[7]= True
This establishes the standard result that the arithmetic mean is larger than the geometric one.
In[8]:= Simplify@Hx + yL ê 2 >= Sqrt@x yD, x >= 0 && y >= 0D
Out[8]= True
This proves that erfHxL lies in the range H0, 1L for all positive arguments.
In[9]:= FullSimplify@0 < Erf@xD < 1, x > 0D
Out[9]= True
Simplify and FullSimplify always try to find the simplest forms of expressions. Sometimes, however, you may just want Mathematica to follow its ordinary evaluation process, but with certain assumptions made. You can do this using Refine. The way it works is that Refine@expr, assumD performs the same transformations as Mathematica would perform automat -ically if the variables in expr were replaced by numerical expressions satisfying the assumptions assum.
There is no simpler form that Simplify can find.
In[10]:= Simplify@Log@xD, x < 0D
Out[10]= Log@xD
Refine just evaluates Log@xD as it would for any explicit negative number x.
In[11]:= Refine@Log@xD, x < 0D
Out[11]= Â p + Log@-xD
An important class of assumptions is those which assert that some object is an element of a particular domain. You can set up such assumptions using x œ dom, where the œ character can be entered as ÇelÇ or î @ElementD.
xœdom or Element@x,domD assert that x is an element of the domain dom 8x1,x2,…<œdom assert that all the xi are elements of the domain dom pattœdom assert that any expression which matches patt is an ele
-ment of the domain dom Asserting that objects are elements of domains.
This confirms that p is an element of the domain of real numbers.
This confirms that p is an element of the domain of real numbers.
In[12]:= Pi œ Reals
Out[12]= True
These numbers are all elements of the domain of algebraic numbers.
In[13]:= 81, Sqrt@2D, 3 + Sqrt@5D< œ Algebraics
Out[13]= True
Mathematica knows that p is not an algebraic number.
In[14]:= Pi œ Algebraics
Out[14]= False
Current mathematics has not established whether e + p is an algebraic number or not.
In[15]:= E + Pi œ Algebraics
Out[15]= ‰ + p œ Algebraics
This represents the assertion that the symbol x is an element of the domain of real numbers.
In[16]:= x œ Reals
Out[16]= x œ Reals
Complexes the domain of complex numbers
Reals the domain of real numbers
Algebraics the domain of algebraic numbers
Rationals the domain of rational numbers
Integers the domain of integers
Primes the domain of primes
Booleans the domain of Booleans (True and False)
Domains supported by Mathematica.
If n is assumed to be an integer, sinHnpL is zero.
In[17]:= Simplify@Sin@n PiD, n œ IntegersD
Out[17]= 0
This establishes the theorem coshHxL ¥ 1 if x is assumed to be a real number.
In[18]:= Simplify@Cosh@xD >= 1, x œ RealsD
Out[18]= True
If you say that a variable satisfies an inequality, Mathematica will automatically assume that it is real.
In[19]:= Simplify@x œ Reals, x > 0D
Out[19]= True
By using Simplify, FullSimplify and FunctionExpand with assumptions you can access many of Mathematica's vast collection of mathematical facts.
This uses the periodicity of the tangent function.
In[20]:= Simplify@Tan@x + Pi kD, k œ IntegersD
Out[20]= Tan@xD
The assumption k ê 2 œ Integers implies that k must be even.
In[21]:= Simplify@Tan@x + Pi k ê 2D, k ê 2 œ IntegersD
Out[21]= Tan@xD
Mathematica knows that logHxL < expHxL for positive x.
In[22]:= Simplify@Log@xD < Exp@xD, x > 0D
Out[22]= True
FullSimplify accesses knowledge about special functions.
In[23]:= FullSimplify@Im@BesselJ@0, xDD, x œ RealsD
Out[23]= 0
Mathematica knows about discrete mathematics and number theory as well as continuous mathematics.
This uses Wilson's theorem to simplify the result.
In[24]:= FunctionExpand@Mod@Hp - 1L !, pD, p œ PrimesD
Out[24]= -1 + p
This uses the multiplicative property of the Euler phi function.
In[25]:= FunctionExpand@EulerPhi@m nD, 8m, n< œ Integers && GCD@m, nD == 1D
Out[25]= EulerPhi@mD EulerPhi@nD
In something like Simplify@expr, assumD or Refine@expr, assumD you explicitly give the assump-tions you want to use. But sometimes you may want to specify one set of assumpassump-tions to use in a whole collection of operations. You can do this by using Assuming.
Assuming@assum,exprD use assumptions assum in the evaluation of expr
$Assumptions the default assumptions to use
Specifying assumptions with larger scopes.
This tells Simplify to use the default assumption x > 0.
In[26]:= Assuming@x > 0, Simplify@Sqrt@x ^ 2DDD
Out[26]= x
This combines the two assumptions given.
In[27]:= Assuming@x > 0, Assuming@x œ Integers, Refine@Floor@Sqrt@x ^ 2DDDDD
Out[27]= x
Functions like Simplify and Refine take the option Assumptions, which specifies what default assumptions they should use. By default, the setting for this option is Assumptions :> $Assumptions. The way Assuming then works is to assign a local value to
$Assumptions, much as in Block.
In addition to Simplify and Refine, a number of other functions take Assumptions options, and thus can have assumptions specified for them by Assuming. Examples are FunctionExpand, Integrate, Limit, Series, LaplaceTransform.
The assumption is automatically used in Integrate.
In[28]:= Assuming@n > 0, 1 + Integrate@x ^ n, 8x, 0, 1<D ^ 2D
Out[28]= 1 + 1 H1 + nL2