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 / Advanced Mathematics in Mathematica / Manipulating Equations and Inequalities /

3.4.8 Inequalities

Just as the equation x^2 + 3x == 2 asserts that x^2 + 3x is equal to 2, so also the inequality x^2 + 3x > 2 asserts that x^2 + 3x is greater than 2. In Mathematica, Reduce works not only on equations, but also on inequalities.

Manipulating univariate inequalities.

This pair of inequalities reduces to a single inequality.

In[1]:= Reduce[{0 < x < 2, 1 < x < 4}, x]

Out[1]=

These inequalities can never simultaneously be satisfied.

In[2]:= Reduce[{x < 1, x > 3}, x]

Out[2]=

When applied to an equation, Reduce[eqn, x] tries to get a result consisting of simple equations for x of the form x == , ... . When applied to an inequality, Reduce[ineq, x] does the exactly analogous thing, and tries to get a result consisting of simple inequalities for x of the form < x < , ... .

This reduces a quadratic equation to two simple equations for x.

In[3]:= Reduce[x^2 + 3x == 2, x]

Out[3]=

This reduces a quadratic inequality to two simple inequalities for x.

In[4]:= Reduce[x^2 + 3x > 2, x]

Out[4]=

You can think of the result generated by Reduce[ineq, x] as representing a series of intervals, described by inequalities. Since the graph of a polynomial of degree can go up and down as many as times, a polynomial inequality of degree can give rise to as many as distinct intervals.

This inequality yields three distinct intervals.

In[5]:= Reduce[(x - 1)(x - 2)(x - 3)(x - 4) > 0, x]

Out[5]=

The ends of the intervals are at roots and poles.

In[6]:= Reduce[1 < (x^2 + 3x)/(x + 1) < 2, x]

Out[6]=

Solving this inequality requires introducing ProductLog.

In[7]:= Reduce[x - 2 < Log[x] < x, x]

Out[7]=

Transcendental functions like have graphs that go up and down infinitely many times, so that infinitely many intervals can be generated.

The second inequality allows only finitely many intervals.

In[8]:= Reduce[{Sin[x] > 0, 0 < x < 20}, x]

Out[8]=

This is how Reduce represents infinitely many intervals.

In[9]:= Reduce[{Sin[x] > 0, 0 < x}, x]

Out[9]=

Fairly simple inputs can give fairly complicated results.

In[10]:= Reduce[{Sin[x]^2 + Sin[3x] > 0, x^2 + 2 < 20}, x]

Out[10]=

If you have inequalities that involve <= as well as <, there may be isolated points where the inequalities can be satisfied. Reduce represents such points by giving equations.

This inequality can be satisfied at just two isolated points.

In[11]:= Reduce[(x^2 - 3x + 1)^2 <= 0, x]

Out[11]=

This yields both intervals and isolated points.

In[12]:= Reduce[{Max[Sin[2x], Cos[3x]] <= 0, 0 < x < 10}, x]

Out[12]=

Multivariate inequalities.

For inequalities involving several variables, Reduce in effect yields nested collections of interval specifications, in which later variables have bounds that depend on earlier variables.

This represents the unit disk as nested inequalities for x and y.

In[13]:= Reduce[x^2 + y^2 < 1, {x, y}]

Out[13]=

In geometrical terms, any linear inequality divides space into two halves. Lists of linear inequalities thus define polyhedra, sometimes bounded, sometimes not. Reduce represents such polyhedra in terms of nested inequalities. The corners of the polyhedra always appear among the endpoints of these inequalities.

This defines a triangular region in the plane.

In[14]:= Reduce[{x > 0, y > 0, x + y < 1}, {x, y}]

Out[14]=

Even a single triangle may need to be described as two components.

In[15]:= Reduce[{x > y - 1, y > 0, x + y < 1}, {x, y}]

Out[15]=

Lists of inequalities in general represent regions of overlap between geometrical objects. Often the description of these can be quite complicated.

This represents the part of the unit disk on one side of a line.

In[16]:= Reduce[{x^2 + y^2 < 1, x + 3y > 2}, {x, y}]

Out[16]=

Here is the intersection between two disks.

In[17]:= Reduce[{(x - 1)^2 + y^2 < 2, x^2 + y^2 < 2}, {x, y}]

Out[17]=

If the disks are too far apart, there is no intersection.

In[18]:= Reduce[{(x - 4)^2 + y^2 < 2, x^2 + y^2 < 2}, {x, y}]

Out[18]=

Here is an example involving a transcendental inequality.

In[19]:= Reduce[{Sin[x y] > 1/2, x^2 + y^2 < 3/2}, {x, y}]

Out[19]=

If you have inequalities that involve parameters, Reduce automatically handles the different cases that can occur, just as it does for equations.

The form of the intervals depends on the value of a.

In[20]:= Reduce[(x - 1)(x - a) > 0, x]

Out[20]=

One gets a hyperbolic or an elliptical region, depending on the value of a.

In[21]:= Reduce[x^2 + a y^2 < 1, {x, y}]

Out[21]=

Reduce tries to give you a complete description of the region defined by a set of inequalities. Sometimes, however, you may just want to find individual instances of values of variables that satisfy the inequalities. You can do this using FindInstance.

Finding individual points that satisfy inequalities.

This finds a specific instance that satisfies the inequalities.

In[22]:= FindInstance[{Sin[x y] > 1/2, x^2 + y^2 < 3/2}, {x, y}]

Out[22]=

This shows that there is no way to satisfy the inequalities.

In[23]:= FindInstance[{Sin[x y] > 1/2, x^2 + y^2 < 1/4}, {x, y}]

Out[23]=

FindInstance is in some ways an analog for inequalities of Solve for equations. For like Solve, it returns a list of rules giving specific values for variables. But while for equations these values can generically give an accurate representation of all solutions, for inequalities they can only correspond to isolated sample points within the regions described by the inequalities.

Every time you call FindInstance with specific input, it will give the same output. And when there are instances that correspond to special, limiting, points of some kind, it will preferentially return these. But in general, the distribution of instances returned by FindInstance will typically seem somewhat random. Each instance is, however, in effect a constructive proof that the inequalities you have given can in fact be satisfied.

If you ask for one point in the unit disk, FindInstance gives the origin.

In[24]:= FindInstance[x^2 + y^2 <= 1, {x, y}]

Out[24]=

This finds 500 points in the unit disk.

In[25]:= FindInstance[x^2 + y^2 <= 1, {x, y}, 500];

Their distribution seems somewhat random.

In[26]:= ListPlot[{x, y} /. %, AspectRatio->Automatic]

Out[26]=