({{, (RefLink[SolveAlways, paclet:ref/SolveAlways])[eqns,vars]
gives the values of parameters that make the equations eqns valid for all values of the variables vars. }})

OpenersNotesSection(Spacer1)Details and Options

Equations are given in the form lhs==rhs.

Simultaneous equations can be combined either in a list or with &&.

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

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

(RefLink[SolveAlways, paclet:ref/SolveAlways]) produces relations between parameters that appear in eqns, but are not in the list of variables vars.

(RefLink[SolveAlways, paclet:ref/SolveAlways])[eqns,vars] is equivalent to (RefLink[Solve, paclet:ref/Solve])[!(RefLink[Eliminate, paclet:ref/Eliminate])[!eqns,vars]].

OpenersPrimaryExamplesSection(Spacer1)Examples  (12)

OpenersExampleSection0(Spacer1)Basic Examples  (1)

Find a condition for the equation to hold for any value of x:

SolveAlways[a x+b==0,x]

OpenersExampleSection1(Spacer1)Scope  (6)

A univariate polynomial equation:

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

A multivariate polynomial equation:

SolveAlways[(a-b)x+(a^2-b+1)x y+(a d-c+2)x y z+a b -c d==0,{x,y,z}]

A list of polynomial equations:

SolveAlways[{(a+b-c)x y-(a-d)==1,(c-d+2)y==(a^2-b)x},{x,y}]

An equation involving radicals:

SolveAlways[Sqrt[a x]==Sqrt[b-1],x]

An inequation:

SolveAlways[a x≠1,x]

Boolean combinations of equations and inequations:

SolveAlways[(a+b)x+c==0&&c x-a b≠0,x]

SolveAlways[(a+b)x+c==0||c x-a b≠0,x]

OpenersExampleSection2(Spacer1)Options  (1)

OpenersExampleSubsection0(Spacer1)WorkingPrecision  (1)

By default, (RefLink[SolveAlways, paclet:ref/SolveAlways]) finds exact solutions:

SolveAlways[(a^2+b^2-1)x+a+2b+5==0,x]

This computes the solutions using 20-digit numbers:

SolveAlways[(a^2+b^2-1)x+a+2b+5==0,x,WorkingPrecision->20]

OpenersExampleSection3(Spacer1)Applications  (2)

Find a condition for a cubic polynomial to have a triple root:

f[x_]:=x^3+a x^2+b x+c;
SolveAlways[Implies[f[x]==0&&f[y]==0,x==y],{x,y}]

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

Reduce[ForAll[{x,y},Implies[f[x]==0&&f[y]==0,x==y]],{a,b,c}]

The same problem can also be solved using (RefLink[Subresultants, paclet:ref/Subresultants]) and (RefLink[Solve, paclet:ref/Solve]):

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

Solve for undetermined coefficients in the series expansion:

y''[x]+2 y[x]==0/.y->Function[x,Sin[a x]]

Series[%,{x,0,3}]

SolveAlways[%,x]

OpenersExampleSection4(Spacer1)Properties & Relations  (1)

Numeric solutions make the equations identically true:

eqns=(a+b-c)x y-(a-d)==1&&(c-d+2)y==(a^2-b)x;
SolveAlways[eqns,{x,y}]

eqns/.%

An equivalent formulation using (RefLink[Solve, paclet:ref/Solve]) and (RefLink[Eliminate, paclet:ref/Eliminate]):

Solve[!Eliminate[!eqns,{x,y}]]

An equivalent formulation using (RefLink[Solve, paclet:ref/Solve]) and (RefLink[Resolve, paclet:ref/Resolve]):

Solve[Resolve[ForAll[{x,y},eqns]]]

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

Reduce[ForAll[{x,y},eqns],{a,b,c,d}]

OpenersExampleSection5(Spacer1)Possible Issues  (1)

(RefLink[SolveAlways, paclet:ref/SolveAlways]) gives generic solutions:

eqns=(a+b)x+c==0||c x-a b≠0;
SolveAlways[eqns,x]

The equations may not be identically true when parameters satisfy additional equations:

eqns/.%

This finds conditions on parameters for which the solutions are not correct:

Resolve[Exists[x,Not[#]]]&/@%

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[Eliminate, paclet:ref/Eliminate])  ▪  (RefLink[Solve, paclet:ref/Solve])  ▪  (RefLink[Reduce, paclet:ref/Reduce])  ▪  (RefLink[PolynomialReduce, paclet:ref/PolynomialReduce])  ▪  (RefLink[ForAll, paclet:ref/ForAll])}})}})

({{DocumentationFooterIconsRelatedTutorial.png, ({{Tutorials}, {▪(RefLinkPlain[Eliminating Variables, paclet:tutorial/EliminatingVariables])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Polynomial Systems, paclet:guide/PolynomialSystems])}})}})