# Equations and Inequalities over Domains

The Wolfram Language normally assumes that variables which appear in equations can stand for arbitrary complex numbers. But when you use Reduce, you can explicitly tell the Wolfram Language that the variables stand for objects in more restricted domains.

Reduce[expr,vars,dom] | reduce eqns over the domain dom |

Complexes | complex numbers |

Reals | real numbers |

Integers | integers |

In[1]:= |

Out[1]= |

In[2]:= |

Out[2]= |

In[3]:= |

Out[3]= |

A single polynomial equation in one variable will always have a finite set of discrete solutions. And in such a case one can think of Reduce[eqns,vars,dom] as just filtering the solutions by selecting the ones that happen to lie in the domain dom.

But as soon as there are more variables, things can become more complicated, with solutions to equations corresponding to parametric curves or surfaces in which the values of some variables can depend on the values of others. Often this dependence can be described by some collection of equations or inequalities, but the form of these can change significantly when one goes from one domain to another.

In[4]:= |

Out[4]= |

In[5]:= |

Out[5]= |

In[6]:= |

Out[6]= |

If your input involves only equations, then Reduce will by default assume that all variables are complex. But if your input involves inequalities, then Reduce will assume that any algebraic variables appearing in them are real, since inequalities can only compare real quantities.

In[7]:= |

Out[7]= |

Complexes | polynomial!=0, x_{i}==Root[…] |

Reals | Root[…]<x_{i}<Root[…], x_{i}==Root[…] |

Integers | arbitrarily complicated |

Schematic building blocks for solutions to polynomial equations and inequalities.

For systems of polynomials over real and complex domains, the solutions always consist of a finite number of components, within which the values of variables are given by algebraic numbers or functions.

In[8]:= |

Out[8]= |

In[9]:= |

Out[9]= |

While in principle Reduce can always find the complete solution to any collection of polynomial equations and inequalities with real or complex variables, the results are often very complicated, with the number of components typically growing exponentially as the number of variables increases.

In[10]:= |

Out[10]= |

As soon as one introduces functions like Sin or Exp, even equations in single real or complex variables can have solutions with an infinite number of components. Reduce labels these components by introducing additional parameters. By default, the parameter in a given solution will be named C[n]. In general you can specify that it should be named by giving the option setting GeneratedParameters->f.

In[11]:= |

Out[11]= |

Reduce can handle equations not only over real and complex variables, but also over integers. Solving such *Diophantine equations* can often be a very difficult problem.

In[12]:= |

Out[12]= |

In[13]:= |

Out[13]= |

In[14]:= |

Out[14]= |

Reduce can solve any system of linear equations or inequalities over the integers. With linear equations in variables, parameters typically need to be introduced. But with inequalities, a much larger number of parameters may be needed.

In[15]:= |

Out[15]= |

With two variables, Reduce can solve any quadratic equation over the integers. The result can be a Fibonacci‐like sequence, represented in terms of powers of quadratic irrationals.

In[16]:= |

Out[16]= |

In[17]:= |

Out[17]= |

Reduce can handle many specific classes of equations over the integers.

In[18]:= |

Out[18]= |

In[19]:= |

Out[19]= |

Equations over the integers sometimes have seemingly quite random collections of solutions. And even small changes in equations can often lead them to have no solutions at all.

For polynomial equations over real and complex numbers, there is a definite *decision procedure* for determining whether or not any solution exists. But for polynomial equations over the integers, the unsolvability of Hilbert’s Tenth Problem demonstrates that there can never be any such general procedure.

For specific classes of equations, however, procedures can be found, and indeed many are implemented in Reduce. But handling different classes of equations can often seem to require whole different branches of number theory, and quite different kinds of computations. And in fact it is known that there are *universal* integer polynomial equations, for which filling in some variables can make solutions for other variables correspond to the output of absolutely any possible program. This then means that for such equations there can never in general be any closed‐form solution built from fixed elements like algebraic functions.

If one includes functions like Sin, then even for equations involving real and complex numbers the same issues can arise.

In[20]:= |

Out[20]= |

Handling equations involving integers modulo .

Since there are only ever a finite number of possible solutions for integer equations modulo , Reduce can systematically find them.

In[21]:= |

Out[21]= |

Reduce can also handle equations that involve several different moduli.

In[22]:= |

Out[22]= |

Reduce[expr,vars,dom] | specify a default domain for all variables |

Reduce[{expr_{1},…,x_{1}∈dom_{1},…},vars] | explicitly specify individual domains for variables |

Different ways to specify domains for variables.

In[23]:= |

Out[23]= |

Reduce normally treats complex variables as single objects. But in dealing with functions that are not analytic or have branch cuts, it sometimes has to break them into pairs of real variables Re[z] and Im[z].

In[24]:= |

Out[24]= |

In[25]:= |

Out[25]= |

Reduce by default assumes that variables that appear algebraically in inequalities are real. But you can override this by explicitly specifying Complexes as the default domain. It is often useful in such cases to be able to specify that certain variables are still real.

In[26]:= |

Out[26]= |

In[27]:= |

Out[27]= |

In[28]:= |

Out[28]= |

In[29]:= |

Out[29]= |

FindInstance[expr,{x_{1},x_{2},…},dom] | try to find an instance of the in dom satisfying expr |

FindInstance[expr,vars,dom,n] | try to find instances |

Complexes | the domain of complex numbers |

Reals | the domain of real numbers |

Integers | the domain of integers |

Booleans | the domain of Booleans (True and False) |

Finding particular solutions in domains.

Reduce always returns a complete representation of the solution to a system of equations or inequalities. Sometimes, however, you may just want to find particular sample solutions. You can do this using FindInstance.

If FindInstance[expr,vars,dom] returns then this means that the Wolfram Language has effectively proved that expr cannot be satisfied for any values of variables in the specified domain. When expr can be satisfied, FindInstance will normally pick quite arbitrarily among values that do this, as discussed for inequalities in "Inequalities: Manipulating Equations and Inequalities".

Particularly for integer equations, FindInstance can often find particular solutions to equations even when Reduce cannot find a complete solution. In such cases it usually returns one of the smallest solutions to the equations.

In[30]:= |

Out[30]= |

One feature of FindInstance is that it also works with Boolean expressions whose variables can have values True or False. You can use FindInstance to determine whether a particular expression is *satisfiable*, so that there is some choice of truth values for its variables that makes the expression True.

In[31]:= |

Out[31]= |

In[32]:= |

Out[32]= |