Wolfram ResearchPRODUCTSPURCHASEFOR USERSCOMPANYOUR SITES
THIS IS DOCUMENTATION FOR AN OBSOLETE PRODUCT.
SEE THE DOCUMENTATION CENTER FOR THE LATEST INFORMATION.
Previous section-----Next section

3.3.11 Using Assumptions

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, assum] refine expr using assumptions
Simplify[expr, assum] simplify with assumptions
FullSimplify[expr, assum] full simplify with assumptions
FunctionExpand[expr, assum] function expand with assumptions

Doing operations with assumptions.
Simplify by default does essentially nothing with this expression.

In[1]:=  Simplify[1/Sqrt[x] - Sqrt[1/x]]

Out[1]=

The reason is that its value is quite different for different choices of  .

In[2]:=  % /. x -> {-3, -2, -1, 1, 2, 3}

Out[2]=

With the assumption  , Simplify can immediately reduce the expression to 0.

In[3]:=  Simplify[1/Sqrt[x] - Sqrt[1/x], x > 0]

Out[3]=

Without making assumptions about  and  , nothing can be done.

In[4]:=  FunctionExpand[Log[x y]]

Out[4]=

If  and  are both assumed positive, the log can be expanded.

In[5]:=  FunctionExpand[Log[x y], x > 0 && y > 0]

Out[5]=

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  the truth or falsity of this equation cannot be determined.

In[6]:=  Simplify[Abs[x] Equal x]

Out[6]=

Now Simplify can prove that the equation is true.

In[7]:=  Simplify[Abs[x] Equal x, x > 0]

Out[7]=

This establishes the standard result that the arithmetic mean is larger than the geometric one.

In[8]:=  Simplify[(x + y)/2 GreaterEqual Sqrt[x y], x GreaterEqual 0 && y GreaterEqual 0]

Out[8]=

This proves that  lies in the range  for all positive arguments.

In[9]:=  FullSimplify[0 < Erf[x] < 1, x > 0]

Out[9]=

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, assum] performs the same transformations as Mathematica would perform automatically 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[x], x < 0]

Out[10]=

Refine just evaluates Log[x] as it would for any explicit negative number x.

In[11]:=  Refine[Log[x], x < 0]

Out[11]=

An important class of assumptions are 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 AliasIndicatorelAliasIndicator or \[Element].

x  dom or Element[x, dom] assert that x is an element of the domain dom
{ ,  , ... }  dom assert that all the  are elements of the domain dom
patt  dom assert that any expression which matches patt is an element of the domain dom

Asserting that objects are elements of domains.
This confirms that  is an element of the domain of real numbers.

In[12]:=  Pi Element Reals

Out[12]=

These numbers are all elements of the domain of algebraic numbers.

In[13]:=  {1, Sqrt[2], 3 + Sqrt[5]} Element Algebraics

Out[13]=

Mathematica knows that  is not an algebraic number.

In[14]:=  Pi Element Algebraics

Out[14]=

Current mathematics has not established whether  is an algebraic number or not.

In[15]:=  E + Pi Element Algebraics

Out[15]=

This represents the assertion that the symbol x is an element of the domain of real numbers.

In[16]:=  x Element Reals

Out[16]=

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  is assumed to be an integer,  is zero.

In[17]:=  Simplify[Sin[n Pi], n Element Integers]

Out[17]=

This establishes the theorem  if  is assumed to be a real number.

In[18]:=  Simplify[Cosh[x] GreaterEqual 1, x Element Reals]

Out[18]=

If you say that a variable satisfies an inequality, Mathematica will automatically assume that it is real.

In[19]:=  Simplify[x Element Reals, x > 0]

Out[19]=

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 k], k Element Integers]

Out[20]=

The assumption k/2  Integers implies that k must be even.

In[21]:=  Simplify[Tan[x + Pi k/2], k/2 Element Integers]

Out[21]=

Mathematica knows that  for positive  .

In[22]:=  Simplify[Log[x] < Exp[x], x > 0]

Out[22]=

FullSimplify accesses knowledge about special functions.

In[23]:=  FullSimplify[Im[BesselJ[0, x]], x Element Reals]

Out[23]=

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[(p - 1)!, p], p Element Primes]

Out[24]=

This uses the multiplicative property of the Euler phi function.

In[25]:=  FunctionExpand[EulerPhi[m n], {m, n} Element Integers &&
GCD[m, n] Equal 1]

Out[25]=

In something like Simplify[expr, assum] or Refine[expr, assum] you explicitly give the assumptions you want to use. But sometimes you may want to specify one set of assumptions to use in a whole collection of operations. You can do this by using Assuming.

Assuming[assum, expr] 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^2]]]

Out[26]=

This combines the two assumptions given.

In[27]:=  Assuming[x > 0,
Assuming[x Element Integers, Refine[Floor[Sqrt[x^2]]]]]

Out[27]=

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, LaplaceTransform.

The assumption is automatically used in Integrate.

In[28]:=  Assuming[n > 0, 1 + Integrate[x^n, {x, 0, 1}]^2]

Out[28]=


Any questions about topics on this page? Click here to get an individual response.Buy NowFree TrialMore Information



 © 2008 Wolfram Research, Inc.  Terms of Use  Privacy Policy |
Sign up for our newsletter: