FindInstance

FindInstance[expr,vars]

finds an instance of vars that makes the statement expr be True.

FindInstance[expr,vars,dom]

finds an instance over the domain dom. Common choices of dom are Complexes, Reals, Integers, and Booleans.

FindInstance[expr,vars,dom,n]

finds n instances.

Details and Options

  • FindInstance[expr,{x1,x2,}] gives results in the same form as Solve: {{x1->val1,x2->val2,}} if an instance exists, and {} if it does not.
  • expr can contain equations, inequalities, domain specifications and quantifiers, in the same form as in Reduce.
  • The statement expr can be any logical combination of:
  • lhs==rhsequations
    lhs!=rhsinequations
    lhs>rhs or lhs>=rhs inequalities
    exprdomdomain specifications
    {x,y,}regregion specification
    ForAll[x,cond,expr]universal quantifiers
    Exists[x,cond,expr]existential quantifiers
  • With exact symbolic input, FindInstance gives exact results.
  • Even if two inputs define the same mathematical set, FindInstance may still pick different instances to return.
  • The instances returned by FindInstance typically correspond to special or interesting points in the set.
  • FindInstance[expr,vars] assumes by default that quantities appearing algebraically in inequalities are real, while all other quantities are complex.
  • FindInstance[expr,vars,Integers] finds solutions to Diophantine equations.
  • FindInstance[expr,vars,Booleans] solves Boolean satisfiability for expr.
  • FindInstance[expr,vars,Reals] assumes that not only vars but also all function values in expr are real. FindInstance[expr&&varsReals,vars] assumes only that the vars are real.
  • FindInstance[,xreg,Reals] constrains x to be in the region reg. The different coordinates for x can be referred to using Indexed[x,i].
  • FindInstance may be able to find instances even if Reduce cannot give a complete reduction.
  • By default, every time you run FindInstance with a given input, it will return the same output.
  • FindInstance[expr,vars,dom,n] will return a shorter list if the total number of instances is less than n.
  • The following options can be given:
  • MethodAutomaticmethod to use
    Modulus 0modulus to assume for integers
    RandomSeeding 1234how to seed randomness
    WorkingPrecision Infinityprecision to use in internal computations

Examples

open allclose all

Basic Examples  (6)

Find a solution instance of a system of equations:

Find a real solution instance of a system of equations and inequalities:

Find an integer solution instance:

Find Boolean values of variables that satisfy a formula:

Find several instances:

Find a point in a geometric region:

Scope  (57)

Complex Domain  (11)

A linear system:

A univariate polynomial equation:

Five roots of a polynomial of a high degree:

A multivariate polynomial equation:

Systems of polynomial equations and inequations:

This gives three solution instances:

If there are no solutions FindInstance returns an empty list:

If there are fewer solutions than the requested number, FindInstance returns all solutions:

Five out of a trillion roots of a polynomial system:

Quantified polynomial system:

An algebraic system:

Transcendental equations:

In this case there is no solution:

A solution in terms of transcendental Root objects:

Five roots of an unrestricted equation:

Systems of transcendental equations:

Three roots of a transcendental system:

Real Domain  (13)

A linear system:

A univariate polynomial equation:

A univariate polynomial inequality:

A multivariate polynomial equation:

A multivariate polynomial inequality:

Systems of polynomial equations and inequalities:

Get four solution instances:

If there are no solutions FindInstance returns an empty list:

If there are fewer solutions than the requested number, FindInstance returns all solutions:

A quantified polynomial system:

An algebraic system:

Piecewise equations:

Piecewise inequalities:

Transcendental equations:

A solution in terms of transcendental Root objects:

Transcendental inequalities:

Transcendental systems:

Integer Domain  (12)

A linear system of equations:

A linear system of equations and inequalities:

Find more than one solution:

A univariate polynomial equation:

A univariate polynomial inequality:

Binary quadratic equations:

A Thue equation:

If there are fewer solutions than the requested number, FindInstance returns all solutions:

A sum of squares equation:

The Pythagorean equation:

A bounded system of equations and inequalities:

A high-degree system with no solution:

Transcendental Diophantine systems:

A polynomial system of congruences:

Modular Domains  (5)

A linear system:

A univariate polynomial equation:

A multivariate polynomial equation:

Find seven instances:

A system of polynomial equations and inequations:

A quantified polynomial system:

Finite Field Domains  (4)

Univariate equations:

Systems of linear equations:

Systems of polynomial equations:

Find three instances:

Systems involving quantifiers:

Mixed Domains  (3)

Mixed real and complex variables:

Find a real value of and a complex value of for which is real and less than :

An inequality involving Abs[z]:

Geometric Regions  (9)

Find instances in basic geometric regions in 2D:

Plot it:

Find instances in basic geometric regions in 3D:

Plot it:

Find a point in the projection of a region:

Plot it:

An implicitly defined region:

A parametrically defined region:

Derived regions:

Plot it:

Regions dependent on parameters:

Find values of parameters , , and for which the circles contain the given points:

Plot it:

Use to specify that is a vector in :

In this case is a vector in :

Options  (3)

Modulus  (1)

Find a solution over the integers modulo 9:

Find three solutions:

RandomSeeding  (1)

Finding instances often involves random choice from large solution sets:

By default, FindInstance chooses the same solutions each time:

Use RandomSeedingAutomatic to generate potentially new instances each time:

WorkingPrecision  (1)

Finding an exact solution to this problem is hard:

With a finite WorkingPrecision, FindInstance is able to find an approximate solution:

Applications  (11)

Geometric Problems  (6)

The region is a subset of if R\S is empty. Show that Disk[{0,0},{2,1}] is a subset of Rectangle[{-2,-1},{2,1}]:

Plot it:

Show that Rectangle[] is a not a subset of Disk[{0,0},7/5]:

Plot it:

Show that Cylinder[]Ball[{0,0,0},2]:

Plot it:

Show that Cylinder[]Ball[{0,0,0},7/5]:

Plot it:

Find a point in the intersection of two regions:

Find a counterexample to a geometric conjecture:

Prove the conjecture using stronger assumptions:

Boolean Problems  (2)

Prove that a statement is a tautology:

This can be proven with TautologyQ as well:

Show that a statement is not a tautology; get a counterexample:

This can be done with SatisfiabilityInstances as well:

Integer Problems  (3)

Find a Pythagorean triple:

Find Pythagorean triples when they exist:

Two instances are now found when :

Find Pythagorean quadruples and visualize the result:

Generate all solutions for and visualize the result:

Show that there are no 2×2 magic squares with all numbers unequal:

Properties & Relations  (10)

Solution instances satisfy the input system:

Use RootReduce to prove that algebraic numbers satisfy equations:

When there are no solutions, FindInstance returns an empty list:

If there are fewer solutions than the requested number, FindInstance returns all solutions:

To get a complete description of the solution set use Reduce:

To get a generic solution of a system of complex equations use Solve:

Solving a sum of squares representation problem:

Use SquaresR to find the number of solutions to sum of squares problems:

Solving a sum of powers representation problem:

Use PowersRepresentations to enumerate all solutions:

Find instances satisfying a Boolean statement:

Use SatisfiabilityInstances to obtain solutions represented as Boolean vectors:

FindInstance shows that the polynomial is non-negative:

Use PolynomialSumOfSquaresList to represent as a sum of squares:

The Motzkin polynomial is non-negative, but is not a sum of squares:

Neat Examples  (1)

Integer solutions for a Thue equation:

Wolfram Research (2003), FindInstance, Wolfram Language function, https://reference.wolfram.com/language/ref/FindInstance.html (updated 2024).

Text

Wolfram Research (2003), FindInstance, Wolfram Language function, https://reference.wolfram.com/language/ref/FindInstance.html (updated 2024).

CMS

Wolfram Language. 2003. "FindInstance." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2024. https://reference.wolfram.com/language/ref/FindInstance.html.

APA

Wolfram Language. (2003). FindInstance. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/FindInstance.html

BibTeX

@misc{reference.wolfram_2024_findinstance, author="Wolfram Research", title="{FindInstance}", year="2024", howpublished="\url{https://reference.wolfram.com/language/ref/FindInstance.html}", note=[Accessed: 05-November-2024 ]}

BibLaTeX

@online{reference.wolfram_2024_findinstance, organization={Wolfram Research}, title={FindInstance}, year={2024}, url={https://reference.wolfram.com/language/ref/FindInstance.html}, note=[Accessed: 05-November-2024 ]}