({{, (RefLink[Solve, paclet:ref/Solve])[expr,vars]
attempts to solve the system expr of equations or inequalities for the variables vars. }, {, (RefLink[Solve, paclet:ref/Solve])[expr,vars,dom]
solves over the domain dom. Common choices of dom are (RefLink[Reals, paclet:ref/Reals]), (RefLink[Integers, paclet:ref/Integers]), and (RefLink[Complexes, paclet:ref/Complexes]).}})

OpenersNotesSection(Spacer1)Details and Options

The system expr can be any logical combination of:

(RefLink[Solve, paclet:ref/Solve])[{(Subscript[expr, 1]),(Subscript[expr, 2]),…},vars] is equivalent to (RefLink[Solve, paclet:ref/Solve])[(Subscript[expr, 1])&&(Subscript[expr, 2])&&…,vars].

A single variable or a list of variables can be specified.

(RefLink[Solve, paclet:ref/Solve]) gives solutions in terms of rules of the form:

When a single variable is specified and a particular root of an equation has multiplicity greater than one, (RefLink[Solve, paclet:ref/Solve]) gives several copies of the corresponding solution.

(RefLink[Solve, paclet:ref/Solve])[expr,vars] assumes by default that quantities appearing algebraically in inequalities are real, while all other quantities are complex.

(RefLink[Solve, paclet:ref/Solve])[expr,vars,dom] restricts all variables and parameters to belong to the domain dom.

If dom is (RefLink[Reals, paclet:ref/Reals]), or a subset such as (RefLink[Integers, paclet:ref/Integers]) or (RefLink[Rationals, paclet:ref/Rationals]), then all constants and function values are also restricted to be real.

(RefLink[Solve, paclet:ref/Solve])[expr&&vars∈(RefLink[Reals, paclet:ref/Reals]),vars,(RefLink[Complexes, paclet:ref/Complexes])] solves for real values of variables, but function values are allowed to be complex.

(RefLink[Solve, paclet:ref/Solve])[expr,vars,(RefLink[Integers, paclet:ref/Integers])] solves Diophantine equations over the integers.

(RefLink[Solve, paclet:ref/Solve])[…,x∈reg,(RefLink[Reals, paclet:ref/Reals])] constrains x to be in the region reg. The different coordinates for x can be referred to using (RefLink[Indexed, paclet:ref/Indexed])[x,i].

Algebraic variables in expr free of the (Subscript[x, i]) and of each other are treated as independent parameters.

(RefLink[Solve, paclet:ref/Solve]) deals primarily with linear and polynomial equations.

When expr involves only polynomial equations and inequalities over real or complex domains, then (RefLink[Solve, paclet:ref/Solve]) can always in principle solve directly for all the (Subscript[x, i]).

When expr involves transcendental conditions or integer domains, (RefLink[Solve, paclet:ref/Solve]) will often introduce additional parameters in its results.

(RefLink[Solve, paclet:ref/Solve]) can give explicit representations for solutions to all linear equations and inequalities over the integers and can solve a large fraction of Diophantine equations described in the literature.

When expr involves only polynomial conditions over real or complex domains, (RefLink[Solve, paclet:ref/Solve])[expr,vars] will always be able to eliminate quantifiers.

(RefLink[Solve, paclet:ref/Solve]) gives generic solutions only. Solutions that are valid only when continuous parameters satisfy equations are removed. Other solutions that are only conditionally valid are expressed as (RefLink[ConditionalExpression, paclet:ref/ConditionalExpression]) objects.

Conditions included in (RefLink[ConditionalExpression, paclet:ref/ConditionalExpression]) solutions may involve inequalities, (RefLink[Element, paclet:ref/Element]) statements, equations and inequations on non-continuous parameters, and equations with full-dimensional solutions. Inequations and (RefLink[NotElement, paclet:ref/NotElement]) conditions on continuous parameters and variables are dropped.

(RefLink[Solve, paclet:ref/Solve]) uses non-equivalent transformations to find solutions of transcendental equations and hence it may not find some solutions and may not establish exact conditions on the validity of the solutions found.

(RefLink[Solve, paclet:ref/Solve]) uses special efficient techniques for handling sparse systems of linear equations with approximate numerical coefficients.

The following options can be given:

With (RefLink[MaxExtraConditions, paclet:ref/MaxExtraConditions])->(RefLink[Automatic, paclet:ref/Automatic]), only solutions that require the minimal number of equational conditions on continuous parameters are included.

With (RefLink[MaxExtraConditions, paclet:ref/MaxExtraConditions])->(RefLink[All, paclet:ref/All]), solutions that require arbitrary conditions on parameters are given and all conditions are included.

With (RefLink[MaxExtraConditions, paclet:ref/MaxExtraConditions])->k, only solutions that require at most k equational conditions on continuous parameters are included.

With (RefLink[Method, paclet:ref/Method])->(RefLink[Reduce, paclet:ref/Reduce]), (RefLink[Solve, paclet:ref/Solve]) uses only equivalent transformations and finds all solutions.

(RefLink[Solve, paclet:ref/Solve])[eqns,…,(RefLink[Modulus, paclet:ref/Modulus])->m] solves equations over the integers modulo m. With (RefLink[Modulus, paclet:ref/Modulus])->(RefLink[Automatic, paclet:ref/Automatic]), (RefLink[Solve, paclet:ref/Solve]) will attempt to find the largest modulus for which the equations have solutions.

OpenersPrimaryExamplesSection(Spacer1)Examples  (117)

OpenersExampleSection0(Spacer1)Basic Examples  (5)

Solve a quadratic equation:

Solve[x^2+a x+1==0,x]

Solve simultaneous equations in x and y:

Solve[a x+y==7&&b x-y==1,{x,y}]

Solve an equation over the reals:

Solve[(x^2+2)(x^2-2)==0,x,Reals]

Solve an equation over the positive integers:

Solve[x^2+2y^3==3681&&x>0 &&y>0,{x,y},Integers]

Solve equations in a geometric region:

Solve[{x,y}∈InfiniteLine[{{0,0},{2,1}}]&&{x,y}∈Circle[],{x,y}]

Graphics[{{Blue,InfiniteLine[{{0,0},{2,1}}],Circle[]},{PointSize[Large],Red,Point[{x,y}]/.%}}]

OpenersExampleSection1(Spacer1)Scope  (73)

OpenersExampleSubsection0(Spacer1)Basic Uses  (6)

Solutions are given as lists of replacements:

sol=Solve[x^2+y^2==2&&x-y==1,{x,y}]

Use (RefLink[ReplaceAll, paclet:ref/ReplaceAll]) (/.) to replace x by solutions:

x/.sol

Check that solutions satisfy the equations:

x^2+y^2==2&&x-y==1/.sol

(RefLink[Solve, paclet:ref/Solve]) uses {} to represent the empty solution or no solution:

Solve[x==1&&x==2,x]

(RefLink[Solve, paclet:ref/Solve]) uses {{}} to represent the universal solution or all points satisfying the equations:

Solve[x==x,x]

Find solutions over specified domains:

Solve[(x^4-1)(x^4-4)==0,x,Complexes]

Solve[(x^4-1)(x^4-4)==0,x,Reals]

Solve[(x^4-1)(x^4-4)==0,x,Integers]

Solve equations with coefficients involving a symbolic parameter:

sol=Solve[x^2+y^2==1&&x+y==a,{x,y}]

Plot the real parts of the solutions for y as a function of the parameter a:

Plot[Evaluate[Re[y/.sol]],{a,0,2}]

Solution of this equation over the reals requires conditions on the parameters:

sol=Solve[x^2+a x+b==0,x,Reals]

Replace x by solutions and simplify the results:

x^2+a x/.sol//Simplify

Use (RefLink[Normal, paclet:ref/Normal]) to remove the conditions:

Normal[sol]

Solution of this equation over the positive integers requires introduction of a new parameter:

sol=Solve[x^2-2y^2==1&&x>0&&y>0,{x,y},Integers]

List the first 10 solutions:

{x,y}/.First[sol]/.Table[{(C[1])->i},{i,10}]//Simplify

OpenersExampleSubsection1(Spacer1)Complex Equations in One Variable  (11)

Polynomial equations solvable in radicals:

Solve[x^4-x^2-5==0,x]

Solve[x^3-2x^2+5x+7==0,x]

General polynomial equations:

Solve[x^5-2x+17==0,x]

Polynomial equations with multiple roots:

Solve[(x^2-1)(x^4-1)==0,x]

Polynomial equations with symbolic coefficients:

Solve[a x^2+b x+c==0,x]

Solve[a x^5+b x+c==0,x]

Algebraic equations:

Solve[Sqrt[x]+3x^(1/3)==5,x]

Transcendental equations:

Solve[Sin[x]==1/3,x]

Solve[x^(2a)+2x^a+1==0,x]

Solve[(x^5-1)^x==0,x]

Solve[5==x*2^(x^2),x]

Solve[ArcTan[1/Sqrt[1+x^2],x/Sqrt[1+x^2]]==a,x]

Univariate elementary function equations over bounded regions:

Solve[Sin[E^x]-Cos[2 x]==1&&-1≤Re[x]≤1&&-1≤Im[x]≤1,x]

Univariate holomorphic function equations over bounded regions:

Solve[Gamma[x]-Log[x]==I/2&&Abs[x-2]<3/2,x]

Here (RefLink[Solve, paclet:ref/Solve]) finds some solutions but is not able to prove there are no other solutions:

Solve[x==E^(1/x)&&Abs[x]<5,x]

Equation with a purely imaginary period over a vertical stripe in the complex plane:

Solve[Cos[Exp[x]]==3 Exp[-x]+1&&0≤Re[x]≤1,x]

Symbolic functions:

Solve[f[x]^3+2f[x]-3==0,x]

OpenersExampleSubsection2(Spacer1)Systems of Complex Equations in Several Variables  (8)

Systems of linear equations:

Solve[{x+2y+3z==4,3x+4y+5z==6,7x+7y+8z==9},{x,y,z}]

Linear equations with symbolic coefficients:

Solve[a x+b y+c z==d &&3x+4y+5z==6&&7x+7y+8z==9,{x,y,z}]

Underdetermined systems of linear equations:

Solve[x+2y+3z==4&&3x+4y+5z==6&&6x+7y+8z==9,{x,y,z}]

Linear equations with no solutions:

Solve[x+2y+3z==4&&3x+4y+5z==6&&6x+7y+8z==0,{x,y,z}]

Systems of polynomial equations:

Solve[x^2+y^2==1&&x+2y==3,{x,y}]

Polynomial equations with symbolic coefficients:

Solve[a x^2+b y^2==c&&x+2y==3,{x,y}]

Algebraic equations:

Solve[Sqrt[x y]==Sqrt[x+y]&&Sqrt[x]-y^(1/3)==1,{x,y}]

Transcendental equations:

Solve[Sin[x+y]==1&&Log[x-y]==1/2,{x,y}]

Solve[3^x^2==7&&x^2-y^3==4,{x,y}]

Solve[x^a+y^b==1&&(x y)^(a b)==2,{x,y}]

OpenersExampleSubsection3(Spacer1)Real Equations in One Variable  (13)

Polynomial equations:

Solve[x^5-2x+1==0,x,Reals]

Polynomial equations with multiple roots:

Solve[(x^2-1)(x^4-1)==0,x,Reals]

Polynomial equations with symbolic coefficients:

Solve[x^3+a x+a^2==0,x,Reals]

Algebraic equations:

Solve[Sqrt[x]+3x^(1/3)==5,x,Reals]

Piecewise equations:

Solve[Abs[x]^2-x+UnitStep[x]==9,x,Reals]

Transcendental equations, solvable using inverse functions:

Solve[E^x-x==7,x,Reals]

Solve[ ((27^(2x-1))^(1/x))==(Sqrt[(9^(2x-1))]), x , Reals]

Transcendental equations, solvable using special function zeros:

Solve[AiryBi[1-x^2]==0&&2<x<3,x,Reals]

Transcendental inequalities, solvable using special function zeros:

Solve[900<AiryAiZero[2t+1]^2<1000,t,Reals]

Exp-log equations:

Solve[E^(2E^x)-Log[x^2+1]-20x==11,x,Reals]

High-degree sparse polynomial equations:

Solve[x^1000000-2x^777777+3x^12345+9x^67-10==0,x,Reals]

Algebraic equations involving high-degree radicals:

Solve[2x^(123451/67890)-x^2+4Sqrt[x]-4x-9/8==0,x,Reals]

Equations involving non-rational real powers:

Solve[x^Pi-x^x^Sqrt[2]-Sqrt[3]x+2^(1/3)==0,x,Reals]

Equation with a double root:

Solve[E^(2x)+x^4+4(x^2+1)==(2x^2+4)E^x,x,Reals]

Tame elementary function equations:

Solve[10Sin[Tan[E^-x^2]]-x==3,x,Reals]

Elementary function equations in bounded intervals:

Solve[2Sin[Exp[x]]-Cos[Pi x]==3/2&&-1<x<1,x,Reals]

Holomorphic function equations in bounded intervals:

Solve[Cos[x]-BesselJ[5,x]==1/2&&0≤x≤10,x]

Periodic elementary function equations over the reals:

Solve[Exp[Sin[x]]-Sin[3 Cos[x]]==0,x,Reals]

OpenersExampleSubsection4(Spacer1)Systems of Real Equations and Inequalities in Several Variables  (9)

Linear systems:

Solve[2 x+3y-5z==1&&3x-4y+7z==3,{y,z},Reals]

Polynomial systems:

Solve[x y==z^2-x&&x y z==2&&x^2+y^2+z^2≤5,{y,z},Reals]

Quantified polynomial systems:

Solve[Exists[x, x^2+a x+b==0&&2 x+a==0],a,Reals]

Solve[ForAll[x,Exists[y,a x^2+b y^2-3y==1&&y<0&&a y-y==b+1]],{a,b},Reals]

Algebraic systems:

Solve[Sqrt[x+2y]-3x+4y≥5&&x+y^(1/3)==1,y,Reals]

Piecewise systems:

Solve[Max[x,y]==Min[y^2-x,x]+y&&z+UnitStep[x-y]==1,{y,z},Reals]

Transcendental systems, solvable using inverse functions:

Solve[Sin[x+y]==1/2&&E^x-y≤1,y,Reals]

Solve[ (3^x)-(2^(2y))==77 && (Sqrt[(3^x)])-(2^y)==7, {x, y}, Reals]

Systems exp-log in the first variable and polynomial in the other variables:

Solve[E^x y^3+Log[x]y==1&&x y+E^x/x≥2,y,Reals]

Quantified system:

Solve[Exists[a,a x^2+Sinh[x^2+1]a^2==1&&x^2-a^2==1],x,Reals]

Systems elementary and bounded in the first variable and polynomial in the other variables:

Solve[Sin[x-Cos[x]] y^3-x==1&&x^2+y^2≤1,y,Reals]

Quantified system:

Solve[Exists[y,y^3-Cos[x] y+2 x^2 Sin[x^2-1]==0&&x^2+y^2==2],x,Reals]

Systems holomorphic and bounded in the first variable and polynomial in the other variables:

Solve[y^3-BesselJ[2,x+2] y-y-3 x==-2&&y<0 &&x^2<2,y,Reals]

Quantified system:

Solve[Exists[y,y^4-Gamma[x+2] y-y-3 ArcSin[x/3]==1&&x^2+y^3==1&&0<x<2],x,Reals]

OpenersExampleSubsection5(Spacer1)Diophantine Equations  (11)

Linear systems of equations:

Solve[2 x+3y-5z==1&&3x-4y+7z==3,{x,y,z},Integers]

Linear systems of equations and inequalities:

Solve[2 x+3y==4&&3x-4y≤5&&x-2y>-21,{x,y},Integers]

Univariate polynomial equations:

Solve[x^12345-2x^777+1==0,x,Integers]

Binary quadratic equations:

Solve[x^2+x y+y^2==109,{x,y},Integers]

Solve[x^2-3y^2==22&&x>0&&y>0,{x,y},Integers]

Solve[x^2-6 x y+9y^2-x+2y==1,{x,y},Integers]

Thue equations:

Solve[x^3-2x^2 y+y^3==2,{x,y},Integers]

Sum of squares equations:

Solve[x^2+4y^2+9z^2+16t^2==354&&x>0&&y>0&&z>0&&t>0,{x,y,z,t},Integers]

The Pythagorean equation:

Solve[x^2+y^2==z^2,{x,y,z},Integers]

Bounded systems of equations and inequalities:

Solve[x^4+y^4+z^4≤500&&x+y^2+z^3==32,{x,y,z},Integers]

High-degree systems with no solutions:

Solve[2x^7+8y^15+14 x y z==3,{x,y,z},Integers]

Transcendental Diophantine systems:

Solve[Exp[y^2]<x&&Abs[x]<5&&Abs[y]<5,{x,y},Integers]

Solve[Exp[x^2-5y^2+1]+x^2-5y^2==0&&x>0&&y>0,{x,y},Integers]

Polynomial systems of congruences:

Solve[Mod[x^2+y^2,2]==1&&Mod[x-2y,3]==2,{x,y},Integers]

OpenersExampleSubsection6(Spacer1)Modular Equations  (4)

Linear systems:

Solve[2 x+3y-5z==1&&3x-4y+7z==3&&2x-10y+3z==5,{x,y,z},Modulus->12]

Solve[2 x+3y-5z==1&&3x-4y+7z==3,{x,y,z},Modulus->12]

Univariate polynomial equations:

Solve[x^3-2x+1==0,x,Modulus->5]

Systems of polynomial equations and inequations:

Solve[x^2+y^3==1&&x+2y^2==4,{x,y},Modulus->7]

Solve[x^2+y^3==z&&x+2y==3z+1&&x y z≠0,{x,y,z},Modulus->7]

Quantified polynomial systems:

Solve[ForAll[x,Exists[y,a x^2+b y^2-3y==1&&y≠0]],{a,b},Modulus->3]

OpenersExampleSubsection7(Spacer1)Systems with Mixed Variable Domains  (2)

Mixed real and complex variables:

Solve[x^2+y^2==1&&Element[x,Reals],y]

Mixed real and integer variables:

Solve[x^2+y^2==7 &&Element[x,Integers]&&Element[y,Reals],{x,y}]

OpenersExampleSubsection8(Spacer1)Geometric Regions  (9)

Solve over special regions in 2D:

(Subscript[ℛ, 1])=Circle[];
(Subscript[ℛ, 2])=Line[{{-2,1},{1,-2}}];

Solve[{x,y}∈(Subscript[ℛ, 1])&&{x,y}∈(Subscript[ℛ, 2]),{x,y}]

Plot it:

Graphics[{{Blue,(Subscript[ℛ, 1]),(Subscript[ℛ, 2])},{Red,Point[{x,y}]/.%}}]

Solve over special regions in 3D:

(Subscript[ℛ, 1])=Sphere[];
(Subscript[ℛ, 2])=InfinitePlane[{{0,0,0},{0,1,0},{1,0,1}}];

Solve[2 x y==(z^2)&&{x,y,z}∈(Subscript[ℛ, 1])&&{x,y,z}∈(Subscript[ℛ, 2]),{x,y,z},Reals]

Plot it:

Show[{ContourPlot3D[2 x y==(z^2),{x,-1.2,1.2},{y,-1.2,1.2},{z,-1.2,1.2},Mesh->None,ContourStyle->Opacity[0.5]],Graphics3D[{{Opacity[0.5],Green,(Subscript[ℛ, 1])},{Opacity[0.5],Yellow,(Subscript[ℛ, 2])},{PointSize[Large],Red,Point[{x,y,z}/.%]}}]}]

A quantified system:

ℛ=Cone[{{0,0,0},{1,2,3}},4];

Solve[(Subscript[∃, z])((x^2)+(y^2)==(z^2)&&x+y==z-1&&{x,y,z}∈ℛ),y,Reals]

An implicitly defined region:

ℛ=ImplicitRegion[a+2 b-3 c≥1&&a b c==7,{a,b,c}];

Solve[(y^2)+x z==1&&{x,y,z}∈ℛ,{y,z},Reals]

A parametrically defined region:

ℛ=ParametricRegion[{s+t,s-t,s t},{s,t}];

Solve[x y==z&&x+2 y+3 z==1&&{x,y,z}∈ℛ,{x,y,z},Reals]

Derived regions:

(Subscript[ℛ, 1])=Disk[{0,0},2];
(Subscript[ℛ, 2])=Circle[{1,1},2];
(Subscript[ℛ, 3])=RegionIntersection[(Subscript[ℛ, 1]),(Subscript[ℛ, 2])];

Solve[(x^2)==x y+1&&{x,y}∈(Subscript[ℛ, 3]),{x,y},Reals]

Plot it:

Show[{ContourPlot[(x^2)==x y+1,{x,-2,3},{y,-2,3}],Graphics[{{Opacity[0.5],Yellow,(Subscript[ℛ, 1])},{Green,(Subscript[ℛ, 2])},{Red,Point[{x,y}/. %]}}]}]

Eliminate quantifiers over a Cartesian product of regions:

ℛ=RegionProduct[Circle[],Circle[]];

Solve[(Subscript[∃, {a,b}])(4 x y a b==1&&{x,a,y,b}∈ℛ),{x,y},Reals]

Regions dependent on parameters:

(Subscript[ℛ, 1])=InfiniteLine[{{2,0},{0,t}}];
(Subscript[ℛ, 2])=Circle[];

The answer depends on the parameter value t:

Solve[{x,y}∈(Subscript[ℛ, 1])&&{x,y}∈(Subscript[ℛ, 2]),{x,y},Reals]

Use x∈ℛ to specify that x is a vector in (ℝ^2):

ℛ=RegionIntersection[Circle[],Line[{{-2,-1},{1,2}}]];

Solve[x∈ℛ,x]

In this case x is a vector in (ℝ^3):

ℛ=Sphere[];

Solve[x.{1,2,3}==0&&x.{-3,-2,-1}==0&&x∈ℛ,x]

OpenersExampleSection2(Spacer1)Generalizations & Extensions  (1)

All variables are solved for:

Solve[x^2+3x+1==0]

Solve[{x+y==2,y-x==1}]

OpenersExampleSection3(Spacer1)Options  (15)

OpenersExampleSubsection9(Spacer1)Cubics  (1)

By default, (RefLink[Solve, paclet:ref/Solve]) uses general formulas for solving cubics in radicals:

Solve[x^3+2 x^2+3 x+4==0,x]

With (RefLink[Cubics, paclet:ref/Cubics])->(RefLink[False, paclet:ref/False]), (RefLink[Solve, paclet:ref/Solve]) does not use the formulas:

Solve[x^3+2 x^2+3 x+4==0,x,Cubics->False]

OpenersExampleSubsection10(Spacer1)GeneratedParameters  (1)

(RefLink[Solve, paclet:ref/Solve]) may introduce new parameters to represent the solution:

Solve[x^2-3y^2==1&&x>0&&y>0,{x,y},Integers]

Use (RefLink[GeneratedParameters, paclet:ref/GeneratedParameters]) to control how the parameters are generated:

Solve[x^2-3y^2==1&&x>0&&y>0,{x,y},Integers,GeneratedParameters->(Subscript[k,#]&)]

OpenersExampleSubsection11(Spacer1)InverseFunctions  (3)

By default, (RefLink[Solve, paclet:ref/Solve]) uses inverse functions but prints warning messages:

Solve[f[x]==0,x]

Solve[x+E^x==1,x]

For symbols with the (RefLink[NumericFunction, paclet:ref/NumericFunction]) attribute, symbolic inverses are not used:

Solve[Gamma[x]==a,x]

With (RefLink[InverseFunctions, paclet:ref/InverseFunctions])->(RefLink[True, paclet:ref/True]), (RefLink[Solve, paclet:ref/Solve]) does not print inverse function warning messages:

Solve[f[x]==0,x,InverseFunctions->True]

Solve[x+E^x==1,x,InverseFunctions->True]

Symbolic inverses are used for all symbols:

Solve[Gamma[x]==a,x,InverseFunctions->True]

With (RefLink[InverseFunctions, paclet:ref/InverseFunctions])->(RefLink[False, paclet:ref/False]), (RefLink[Solve, paclet:ref/Solve]) does not use inverse functions:

Solve[f[x]==0,x,InverseFunctions->False]

Solving algebraic equations does not require using inverse functions:

Solve[x^2+1==0,x,InverseFunctions->False]

Here, a method based on (RefLink[Reduce, paclet:ref/Reduce]) is used, as it does not require using inverse functions:

Solve[x+E^x==1,x,InverseFunctions->False]

OpenersExampleSubsection12(Spacer1)MaxExtraConditions  (4)

By default, no solutions requiring extra conditions are produced:

Solve[a==0&&x==0,x]

Unless the parameters are discrete:

Solve[a==0&&x==0,x,Integers]

The default setting, (RefLink[MaxExtraConditions, paclet:ref/MaxExtraConditions])->0, gives no solutions requiring conditions:

Solve[(x-a)(x-b)==0&&(x-c)(x-d)==0&& (x-a)(x-e)==0,x]

Solve[(x-a)(x-b)==0&&(x-c)(x-d)==0&& (x-a)(x-e)==0,x,MaxExtraConditions->0]

(RefLink[MaxExtraConditions, paclet:ref/MaxExtraConditions])->1 gives solutions requiring up to one equation on parameters:

Solve[(x-a)(x-b)==0&&(x-c)(x-d)==0&& (x-a)(x-e)==0,x,MaxExtraConditions->1]

(RefLink[MaxExtraConditions, paclet:ref/MaxExtraConditions])->2 gives solutions requiring up to two equations on parameters:

Solve[(x-a)(x-b)==0&&(x-c)(x-d)==0&& (x-a)(x-e)==0,x,MaxExtraConditions->2]

Give solutions requiring the minimal number of parameter equations:

Solve[(x-a)(x-b)==0&&(x-c)(x-d)==0&& (x-a)(x-e)==0,x,MaxExtraConditions->Automatic]

Give all solutions:

Solve[(x-a)(x-b)==0&&(x-c)(x-d)==0&& (x-a)(x-e)==0,x,MaxExtraConditions->All]

By default, (RefLink[Solve, paclet:ref/Solve]) drops inequation conditions on continuous parameters:

Solve[a x==1,x]

With (RefLink[MaxExtraConditions, paclet:ref/MaxExtraConditions])->(RefLink[All, paclet:ref/All]), (RefLink[Solve, paclet:ref/Solve]) includes all conditions:

Solve[a x==1,x,MaxExtraConditions->All]

OpenersExampleSubsection13(Spacer1)Method  (1)

By default, (RefLink[Solve, paclet:ref/Solve]) uses inverse functions to solve non-polynomial complex equations:

Solve[x E^x==1/2,x]

With (RefLink[Method, paclet:ref/Method])->(RefLink[Reduce, paclet:ref/Reduce]), (RefLink[Solve, paclet:ref/Solve]) uses (RefLink[Reduce, paclet:ref/Reduce]) to find the complete solution set:

Solve[x E^x==1/2,x,Method->Reduce]

OpenersExampleSubsection14(Spacer1)Modulus  (2)

Solve equations over the integers modulo 9:

Solve[x^2+3y^2==4&&3x^3-4y^2+x y==1,{x,y},Modulus->9]

Find a modulus for which a system of equations has a solution:

Solve[x^2+y^2==1&&2x+3y==5&&x^3-x y==7,{x,y},Modulus->Automatic]

OpenersExampleSubsection15(Spacer1)Quartics  (1)

By default, (RefLink[Solve, paclet:ref/Solve]) uses the general formulas for solving quartics in radicals:

Solve[x^4+2 x^2+3 x+4==0,x][[1]]

With (RefLink[Quartics, paclet:ref/Quartics])->(RefLink[False, paclet:ref/False]), (RefLink[Solve, paclet:ref/Solve]) does not use the formulas:

Solve[x^4+2 x^2+3 x+4==0,x,Quartics->False]

OpenersExampleSubsection16(Spacer1)VerifySolutions  (1)

(RefLink[Solve, paclet:ref/Solve]) verifies solutions obtained using non-equivalent transformations:

eqns=Sqrt[x+Sqrt[x]]==2&&y^9-y-2 x^(1/7)==3;
(sol1=Solve[eqns,{x,y}]);//Timing

With (RefLink[VerifySolutions, paclet:ref/VerifySolutions])->(RefLink[False, paclet:ref/False]), (RefLink[Solve, paclet:ref/Solve]) does not verify the solutions:

(sol2=Solve[eqns,{x,y},VerifySolutions->False]);//Timing

Some of the solutions returned with (RefLink[VerifySolutions, paclet:ref/VerifySolutions])->(RefLink[False, paclet:ref/False]) are not correct:

Length/@{sol1, sol2}

This uses a fast numeric test in an attempt to select correct solutions:

(sol3=Select[sol2,TrueQ[eqns/.N[#,20]]&]);//Timing

In this case numeric verification gives the correct solution set:

sol3===sol1

OpenersExampleSubsection17(Spacer1)WorkingPrecision  (1)

By default, (RefLink[Solve, paclet:ref/Solve]) finds exact solutions of equations:

SeedRandom[0];
mat=Table[RandomInteger[{-10^100,10^100}], {200},{200}];
b=Table[RandomInteger[{-10^100,10^100}],{200}];
vars=x/@Range[200];
(sol=Solve[Thread[mat.vars==b],vars]);//Timing

Computing the solution using 100-digit numbers is faster:

(sol1=Solve[Thread[mat.vars==b],vars,WorkingPrecision->100]);//Timing

The result agrees with the exact solution in the first 100 digits:

Max[Abs[(vars/.sol)-(vars/.sol1)]]

Computing the solution using machine numbers is much faster:

(sol2=Solve[Thread[mat.vars==b],vars,WorkingPrecision->MachinePrecision]);//Timing

The result is still quite close to the exact solution:

Max[Abs[(vars/.sol)-(vars/.sol2)]]

OpenersExampleSection4(Spacer1)Applications  (6)

Solve a quadratic equation:

Solve[a x^2+b x+c==0,x]

Find intersection points of a circle and a parabola:

pts=Solve[x^2+y^2==1&&y-2x^2+3/2==0,{x,y}]

Show[{ContourPlot[{x^2+y^2==1,y-2x^2+3/2==0},{x,-1.5,1.5},{y,-1.5,1.5}],Graphics[{Red,PointSize[Medium],Point[{x,y}/.pts]}]}]

Find conditions for a quartic to have all roots equal:

f[x_]:= x^4 + a x^3 + b x^2 + c x + d

A method using (RefLink[Subresultants, paclet:ref/Subresultants]):

Solve[Thread[Drop[Subresultants[f[x],D[f[x],x],x],-1]==0],{b,c,d}]

A method using quantifier elimination:

Solve[Exists[x,f[x]==0,ForAll[y,f[y]==0, x==y]],{b,c,d}]

Plot a space curve given by an implicit description:

curve=x^2+y^2+z^2==1&&x^3+x y^2==z^2;

sol=Solve[curve,{y,z},Reals]

cond=Union[#[[2]]&/@Cases[sol, _ConditionalExpression, Infinity]]

{l,u}=N[{cond[[1,1]],cond[[1,5]]}]

ParametricPlot3D[{x,y,z}/.sol,{x,l,u}]

Plot the projection of the space curve on the {x,y} plane:

proj=Solve[Exists[z,curve],y,Reals]

ParametricPlot[{x,y}/.proj,{x,l,u}]

Find a Pythagorean triple:

Solve[x^2+y^2==5^2&&y>x>0,{x,y},Integers]

Find a sequence of Pythagorean triples:

Table[Solve[x^2+y^2==z^2&&y>x>0,{x,y},Integers],{z,30}]

Find how to pay $2.27 postage with 10-, 23-, and 37-cent stamps:

Solve[a 10 + b 23 + c 37 == 227 &&a>=0&&b>=0&&c>=0,{a,b,c},Integers]

The same task can be accomplished with (RefLink[IntegerPartitions, paclet:ref/IntegerPartitions]):

IntegerPartitions[227,All,{37,23,10}]

OpenersExampleSection5(Spacer1)Properties & Relations  (13)

Solutions satisfy the equations:

eqns={x^2+y^2==1&&2x+3y==4};
Solve[eqns,{x,y}]

Solutions are given as replacement rules and can be directly used for substitution:

eqns/.%

(RefLink[Solve, paclet:ref/Solve]) uses {} to represent the empty solution or no solution:

Solve[x==1&&x==2,x]

(RefLink[Solve, paclet:ref/Solve]) uses {{}} to represent the universal solution or all points satisfying the equations:

Solve[x==x,x]

For univariate equations, (RefLink[Solve, paclet:ref/Solve]) repeats solutions according to their multiplicity:

Solve[(x-1)^2(x-2)^3==0,x]

Solutions of algebraic equations are often given in terms of (RefLink[Root, paclet:ref/Root]) objects:

Solve[x^5-2x+7==0,x]

Use (RefLink[N, paclet:ref/N]) to compute numeric approximations of (RefLink[Root, paclet:ref/Root]) objects:

N[%,20]

(RefLink[Root, paclet:ref/Root]) objects may involve parameters:

Solve[x^5+a x+1==0,x]

Use (RefLink[Series, paclet:ref/Series]) to compute series expansions of (RefLink[Root, paclet:ref/Root]) objects:

Series[x/.%[[1]],{a,0,10}]

The series satisfies the equation up to order 11:

x^5+a x+1/.x->%

(RefLink[Solve, paclet:ref/Solve]) represents solutions in terms of replacement rules:

Solve[x^4==4,x]

(RefLink[Reduce, paclet:ref/Reduce]) represents solutions in terms of Boolean combinations of equations and inequalities:

Reduce[x^4==4,x]

(RefLink[Solve, paclet:ref/Solve]) uses fast heuristics to solve transcendental equations, but may give incomplete solutions:

Solve[x-E^x==1, x]

Solve[x Log[x]==a,x]

(RefLink[Reduce, paclet:ref/Reduce]) uses methods that are often slower, but finds all solutions and gives all necessary conditions:

Reduce[x-E^x==1,x]

Reduce[x Log[x]==a,x]

Use (RefLink[FindInstance, paclet:ref/FindInstance]) to find solution instances:

FindInstance[x^2+y^2+z^2==1&&2x y==z^3,{x,y,z}]

Like (RefLink[Reduce, paclet:ref/Reduce]), (RefLink[FindInstance, paclet:ref/FindInstance]) can be given inequalities and domain specifications:

FindInstance[x^2-3y^2==1&&0<x<10^10,{x,y},Integers,3]

Use (RefLink[DSolve, paclet:ref/DSolve]) to solve differential equations:

DSolve[y''[x]==-y[x],y[x],x]

DSolve[{y''[x]==-y[x],y[0]==0,y'[0]==1},y[x],x]

Use (RefLink[RSolve, paclet:ref/RSolve]) to solve recurrence equations:

RSolve[f[n+1]==n f[n],f[n],n]

RSolve[{f[n+1]==n+f[n],f[0]==0},f[n],n]

(RefLink[SolveAlways, paclet:ref/SolveAlways]) gives the values of parameters for which complex equations are always true:

SolveAlways[(a -2b+1)x^2+(a-b^2-c)x ==a^2-b+3c-1,x]

The same problem can be expressed using (RefLink[ForAll, paclet:ref/ForAll]) and solved with (RefLink[Solve, paclet:ref/Solve]) or (RefLink[Reduce, paclet:ref/Reduce]):

Solve[ForAll[x,(a -2b+1)x^2+(a-b^2-c)x ==a^2-b+3c-1],{a,b,c}]

Reduce[ForAll[x,(a -2b+1)x^2+(a-b^2-c)x ==a^2-b+3c-1],{a,b,c}]

(RefLink[Resolve, paclet:ref/Resolve]) eliminates quantifiers, possibly without solving the resulting quantifier-free system:

Resolve[Exists[x,x^2+y^2+z^2==1&&x y>z^3],Reals]

Resolve[ForAll[{x,y},a x^2+b x+c==0&&a y^2+b y+c==0,x==y]]

(RefLink[Eliminate, paclet:ref/Eliminate]) eliminates variables from systems of complex equations:

Eliminate[x^2+y^2+z^2==1&&x z==y^3,x]

This solves the same problem using (RefLink[Resolve, paclet:ref/Resolve]):

Resolve[Exists[x,x^2+y^2+z^2==1&&x z==y^3]]

(RefLink[Reduce, paclet:ref/Reduce]) and (RefLink[Solve, paclet:ref/Solve]) additionally solve the resulting equations:

Reduce[Exists[x,x^2+y^2+z^2==1&&x z==y^3],{y,z}]

Solve[Exists[x,x^2+y^2+z^2==1&&x z==y^3],z]

OpenersExampleSection6(Spacer1)Possible Issues  (4)

(RefLink[Solve, paclet:ref/Solve]) gives generic solutions; solutions involving equations on parameters are not given:

Solve[a x^2+x==1,x]

(RefLink[Reduce, paclet:ref/Reduce]) gives all solutions, including those that require equations on parameters:

Reduce[a x^2+x==1,x]

With (RefLink[MaxExtraConditions, paclet:ref/MaxExtraConditions])->(RefLink[All, paclet:ref/All]), (RefLink[Solve, paclet:ref/Solve]) also gives non-generic solutions:

Solve[a x^2+x==1,x,MaxExtraConditions->All]

(RefLink[Solve, paclet:ref/Solve]) results do not depend on whether some of the input equations contain only parameters. The following two systems are equivalent and have no generic solutions:

Solve[x==1&& a==2,x]

Solve[x==1&&x+a==x+2,x]

Use (RefLink[MaxExtraConditions, paclet:ref/MaxExtraConditions]) to specify the number of parameter conditions allowed:

Solve[x==1&& a==2,x,MaxExtraConditions->1]

Solve[x==1&& x+a==x+2,x,MaxExtraConditions->1]

Use the (RefLink[Exists, paclet:ref/Exists]) quantifier to find solutions that are valid for some value of parameter a:

Solve[Exists[a,x==1&& a==2],x]

Solve[Exists[a,x==1&& x+a==x+2],x]

(RefLink[Solve, paclet:ref/Solve]) does not eliminate solutions that are neither generically correct nor generically incorrect:

Solve[Sqrt[((1-z)/(1+z))^2]==(1-a)/(1+a),z]

The solutions are correct for 0<\[LeftBracketingBar]a\[RightBracketingBar]<1 and incorrect for \[LeftBracketingBar]a\[RightBracketingBar]>1:

Sqrt[((1-z)/(1+z))^2]-(1-a)/(1+a)/.%/.{{a->(2+3I)/4},{a->2+3I}}

For transcendental equations, (RefLink[Solve, paclet:ref/Solve]) may not give all solutions:

Solve[x+E^x==1/2,x]

Use (RefLink[Reduce, paclet:ref/Reduce]) to get all solutions:

Reduce[x+E^x==1/2,x]

(RefLink[Solve, paclet:ref/Solve]) with (RefLink[Method, paclet:ref/Method])->"Reduce" uses (RefLink[Reduce, paclet:ref/Reduce]) to find solutions, but returns replacement rules:

Solve[x+E^x==1/2,x,Method->"Reduce"]

Using inverse functions allows (RefLink[Solve, paclet:ref/Solve]) to find some solutions fast:

Solve[x^n==1,x]//Timing

Finding the complete solution may take much longer, and the solution may be large:

(red=Reduce[x^n==1,x])//LeafCount//Timing

This finds the values of n for which x==2 is a solution:

Reduce[red/.x->2,n]

Simplify[x^n/.{x->2,n->2I Pi (C[1])/Log[2]},Element[(C[1]),Integers]]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[Root, paclet:ref/Root])  ▪  (RefLink[Reduce, paclet:ref/Reduce])  ▪  (RefLink[FindInstance, paclet:ref/FindInstance])  ▪  (RefLink[NSolve, paclet:ref/NSolve])  ▪  (RefLink[FindRoot, paclet:ref/FindRoot])  ▪  (RefLink[AsymptoticSolve, paclet:ref/AsymptoticSolve])  ▪  (RefLink[Eliminate, paclet:ref/Eliminate])  ▪  (RefLink[SolveAlways, paclet:ref/SolveAlways])  ▪  (RefLink[LinearSolve, paclet:ref/LinearSolve])  ▪  (RefLink[RowReduce, paclet:ref/RowReduce])  ▪  (RefLink[ToRadicals, paclet:ref/ToRadicals])  ▪  (RefLink[GroebnerBasis, paclet:ref/GroebnerBasis])  ▪  (RefLink[CylindricalDecomposition, paclet:ref/CylindricalDecomposition])  ▪  (RefLink[DSolve, paclet:ref/DSolve])  ▪  (RefLink[RSolve, paclet:ref/RSolve])  ▪  (RefLink[ContourPlot, paclet:ref/ContourPlot])  ▪  (RefLink[ContourPlot3D, paclet:ref/ContourPlot3D])  ▪  (RefLink[RegionPlot, paclet:ref/RegionPlot])  ▪  (RefLink[RegionPlot3D, paclet:ref/RegionPlot3D])  ▪  (RefLink[GeometricScene, paclet:ref/GeometricScene])}})}})

({{DocumentationFooterIconsRelatedTutorial.png, ({{Tutorials}, {▪(RefLinkPlain[Symbolic Mathematics: Basic Operations, paclet:tutorial/SymbolicCalculations])}, {▪(RefLinkPlain[Solving Equations, paclet:tutorial/SolvingEquations])}, {▪(RefLinkPlain[Simultaneous Equations, paclet:tutorial/SimultaneousEquations])}, {▪(RefLinkPlain[Solving Equations Involving Power Series, paclet:tutorial/SolvingEquationsInvolvingPowerSeries])}, {▪(RefLinkPlain[Solving Linear Systems, paclet:tutorial/SolvingLinearSystems])}, {▪(RefLinkPlain[Solving Logical Combinations of Equations, paclet:tutorial/SolvingLogicalCombinationsOfEquations])}, {▪(RefLinkPlain[Generic and Non-Generic Solutions, paclet:tutorial/GenericAndNonGenericSolutions])}, {▪(RefLinkPlain[Eliminating Variables, paclet:tutorial/EliminatingVariables])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Equation Solving, paclet:guide/EquationSolving])}, {▪(RefLinkPlain[Polynomial Algebra, paclet:guide/PolynomialAlgebra])}, {▪(RefLinkPlain[Polynomial Equations, paclet:guide/PolynomialEquations])}, {▪(RefLinkPlain[Solvers over Regions, paclet:guide/GeometricSolvers])}, {▪(RefLinkPlain[Polynomial Systems, paclet:guide/PolynomialSystems])}, {▪(RefLinkPlain[Plane Geometry, paclet:guide/PlaneGeometry])}, {▪(RefLinkPlain[Solid Geometry, paclet:guide/SolidGeometry])}, {▪(RefLinkPlain[Polygons, paclet:guide/Polygons])}, {▪(RefLinkPlain[Precollege Education, paclet:guide/PrecollegeEducation])}, {▪(RefLinkPlain[Polyhedra, paclet:guide/Polyhedra])}, {▪(RefLinkPlain[Geometric Computation, paclet:guide/GeometricComputation])}, {▪(RefLinkPlain[Additive Number Theory, paclet:guide/AdditiveNumberTheory])}})}})