Solving Equations
This worksheet contains various commented examples that demonstrate the Maple powerful equation solver, solve.
restart
An Introduction to the solve Command
The first example, which is the canonical example for this algorithm, is the following:
eqns:=xa⁢yb−U,1+μ⁢xa⁢a⁢ybx,1+μ⁢xa⁢yb⁢by
eqns≔1+μ⁢xa⁢a⁢ybx,1+μ⁢xa⁢yb⁢by,xa⁢yb−U
The difficulty here lies on xa and x, and also on yb and y, for which an unknown a and b cannot be related together in a polynomial form.
solve⁡eqns,x,y,μ
x=ⅇ−ln⁡ba⁢b−ln⁡Ub+a,y=ⅇln⁡ba⁢a+ln⁡Ub+a,μ=−ⅇln⁡ba⁢a+ln⁡Ub+aU⁢b
The same equation, even when xa and yb are replaced by arbitrary functions, can still be solved in terms of the inverses of these arbitrary functions.
eqns:=A⁡x⁢B⁡y−U,1+μ⁢A⁡x⁢a⁢B⁡yx,1+μ⁢A⁡x⁢B⁡y⁢by
eqns≔1+μ⁢A⁡x⁢a⁢B⁡yx,1+μ⁢A⁡x⁢B⁡y⁢by,A⁡x⁢B⁡y−U
Solving gives
x=−RootOf⁡−A⁡−_Z⁢U⁢a⁢B⁡−_Z⁢U⁢b+U⁢U⁢a,y=−RootOf⁡−A⁡−_Z⁢U⁢a⁢B⁡−_Z⁢U⁢b+U⁢U⁢b,μ=RootOf⁡−A⁡−_Z⁢U⁢a⁢B⁡−_Z⁢U⁢b+U
Carefully Solving Equations
These problems require the correct treatment of trigonometrics and exponentials, because the determinant is zero and no solutions exist.
eqns:=2⋅x⋅cos1+y=1,sin2⋅x+sin1⋅y=0
eqns≔2⁢x⁢cos⁡1+y=1,sin⁡2⁢x+sin⁡1⁢y=0
solve⁡eqns,x,y
eqns:=sinw⋅x+1−cos⁡w⋅y=5,1+cos⁡w⋅x+sinw⋅y=3
eqns≔1+cos⁡w⁢x+sin⁡w⁢y=3,sin⁡w⁢x+1−cos⁡w⁢y=5
solveeqns,w,x,y
w=−arctan⁡158+π,x=−5⁢y3+173,y=y
Equations and Inequalities Involving Exponentials, Logarithms, and Powers
The following examples involve exponentials or logarithms (where the answer can be expressed as rational expressions), and the use of the LambertW function. For example,;
eqns:=x2=2x
eqns≔x2=2x
solve⁡eqns,x
x=2,x=4,x=−2⁢LambertW⁡ln⁡22ln⁡2
The following problem stems from an exponential data fit.
e1:=46=Ts+ⅇ0⋅A:
e2:=39=Ts+ⅇ10⁢a⋅A:
e3:=33=Ts+ⅇ20⁢a⋅A:
eqns:=e1,e2,e3
eqns≔33=Ts+ⅇ20⁢a⁢A,39=Ts+ⅇ10⁢a⁢A,46=Ts+A
solve⁡eqns,Ts,A,a
Ts=−3,A=49,a=ln⁡6710
Here are some examples of exponentials mixed in inequalities.
eqns:=ⅇx+x≤1
eqns≔ⅇx+x≤1
x≤0
eqns≔x⋅x+ⅇx>0
eqns≔0<x⁢x+ⅇx
−2⁢LambertW⁡12<x
eqns:=12≤ⅇx⋅x2
eqns≔12≤ⅇx⁢x2
solveeqns,x;
x≤2⁢LambertW⁡−24,2⁢LambertW⁡−1,−24≤x,2⁢LambertW⁡24≤x
evalf⁡
x≤−1.487962064,−2.617866616≤x,0.5398352768≤x
You can also solve equations involving powers.
eqns:=a2 x−ax2+ax3=2
eqns≔a2⁢x−ax2+ax3=2
x=6⁢ln⁡RootOf⁡_Z12−_Z3+_Z2−2,index=1ln⁡a,x=6⁢ln⁡RootOf⁡_Z12−_Z3+_Z2−2,index=2ln⁡a,x=6⁢ln⁡RootOf⁡_Z12−_Z3+_Z2−2,index=3ln⁡a,x=6⁢ln⁡RootOf⁡_Z12−_Z3+_Z2−2,index=4ln⁡a,x=6⁢ln⁡RootOf⁡_Z12−_Z3+_Z2−2,index=5ln⁡a,x=6⁢ln⁡RootOf⁡_Z12−_Z3+_Z2−2,index=6ln⁡a,x=6⁢ln⁡RootOf⁡_Z12−_Z3+_Z2−2,index=7ln⁡a,x=6⁢ln⁡RootOf⁡_Z12−_Z3+_Z2−2,index=8ln⁡a,x=6⁢ln⁡RootOf⁡_Z12−_Z3+_Z2−2,index=9ln⁡a,x=6⁢ln⁡RootOf⁡_Z12−_Z3+_Z2−2,index=10ln⁡a,x=6⁢ln⁡RootOf⁡_Z12−_Z3+_Z2−2,index=11ln⁡a,x=6⁢ln⁡RootOf⁡_Z12−_Z3+_Z2−2,index=12ln⁡a
eqns:=x+1x+a=x+13
eqns≔x+1x+a=x+13
x=0,x=3−a,x=−1
eqns:=x5−1x
eqns≔x5−1x
x=1,x=RootOf⁡_Z4+_Z3+_Z2+_Z+1,index=1,x=RootOf⁡_Z4+_Z3+_Z2+_Z+1,index=4
abs, signum, and csgn
Some of these examples may cause ranges to be returned.
eqns:=z+z+22−12=9
eqns≔z+z+22−12=9
solve⁡eqns,z
z≤−2,z=0
eqns:=z2z−1<ⅇ2ⅇ−1
eqns≔z2z−1<ⅇ2ⅇ−1
z<1,z<ⅇ2+ⅇ22−4⁢ⅇ2⁢ⅇ+4⁢ⅇ22⁢ⅇ−1,−−ⅇ2+ⅇ22−4⁢ⅇ2⁢ⅇ+4⁢ⅇ22⁢ⅇ−1<z
eqns:=x2<1,y2≤1,x+y<12
eqns≔y2≤1,x2<1,x+y<12
x<−12,−1<x,y≤1,−1≤y,x=−12,y<1,−1≤y,x<1,−12<x,y=−1,x<1,−12<x,y<−x+12,−1<y
eqns:=x+y+4x+y<10
eqns≔x+y+4x+y<10
x<−y,x<−y+5+21,−y+5−21<x
eqns:=signum⁡x⁢x<x−4⁢4−x⁢x
eqns≔signum⁡x⁢x<x−42⁢x
5<x,x<3,0<x
eqns:=csgn⁡x=x
eqns≔csgn⁡x=x
x=0,x=1
The following example is verified for six different intervals in x.
eqns:=1x2−1<x3−2⁢x2−5⁢x+1
eqns≔1x2−1<x3−2⁢x2−5⁢x+1
x<RootOf⁡_Z5−2⁢_Z4−6⁢_Z3+3⁢_Z2+5⁢_Z−2,index=4,RootOf⁡_Z5−2⁢_Z4−6⁢_Z3+3⁢_Z2+5⁢_Z−2,index=5<x,RootOf⁡_Z5−2⁢_Z4−6⁢_Z3+3⁢_Z2+5⁢_Z−2,index=3<x,x<RootOf⁡_Z4−2⁢_Z3−6⁢_Z2+3⁢_Z+5,index=4,x<RootOf⁡_Z4−2⁢_Z3−6⁢_Z2+3⁢_Z+5,index=2,RootOf⁡_Z4−2⁢_Z3−6⁢_Z2+3⁢_Z+5,index=1<x,x<0,RootOf⁡_Z4−2⁢_Z3−6⁢_Z2+3⁢_Z+5,index=3<x,x<RootOf⁡_Z5−2⁢_Z4−6⁢_Z3+3⁢_Z2+5⁢_Z−2,index=2,RootOf⁡_Z5−2⁢_Z4−6⁢_Z3+3⁢_Z2+5⁢_Z−2,index=1<x
x<−1.187054561,−1.468115597<x,3.394451740<x,x<−1.640158839,x<3.382444102,1.086913325<x,x<0.,−0.8291985883<x,x<0.8738032298,0.3869151880<x
Linear Programming and Simplex Problems
eqns:=0≤y,0≤x−y,x+y≤0
eqns≔0≤y,0≤x−y,x+y≤0
x=0,y=0
eqns:=2≤x+y,x−2 y≤1,0≤x−y,y−x2≤−12
eqns≔0≤x−y,2≤x+y,x−2⁢y≤1,y−x2≤−12
53≤x,y=x2−12
Other Modes of Solving
eqns:=identity⁡1x2−1=AC⁢x+1+BD⁢x−1,x
eqns≔identity⁡1x2−1=AC⁢x+1+BD⁢x−1,x
solve⁡eqns,A,B,C,D
A=−12,B=12,C=1,D=1,A=−12,B=12,C=−1,D=−1
eqns:=identity⁡sinx=a⋅ⅇb⁢x+c⋅ⅇd⁢x,x
eqns≔identity⁡sin⁡x=a⁢ⅇb⁢x+c⁢ⅇd⁢x,x
solve⁡eqns,a,b,c,d
a=I2,b=−I,c=−I2,d=I,a=−I2,b=I,c=I2,d=−I
eqns:=ⅇx<3 x or 5⁢x<ⅇxandⅇx<6⁢x
eqns≔ⅇx<3⁢xor5⁢x<ⅇx<6⁢x
x<−LambertW⁡−1,−13,−LambertW⁡−13<x,x<−LambertW⁡−15,−LambertW⁡−16<x,x<−LambertW⁡−1,−16,−LambertW⁡−1,−15<x
x<1.512134552,0.6190612867<x,x<0.2591711018,0.2044814493<x,x<2.833147892,2.542641358<x
_EnvExplicit:=true:
eqns:=x6+8,x2+2≠0
eqns≔x6+8,x2+2≠0
_EnvExplicit:='_EnvExplicit':
x=1−I⁢3,x=−1−I⁢3,x=1+I⁢3,x=−1+I⁢3
Special Functions
eqns≔Ψ3⁢x−99−Ψ3⁢x−100+3x2
eqns≔Ψ⁡3⁢x−99−Ψ⁡3⁢x−100+3x2
x=−92+12812,x=−92−12812
eqns:=max⁡x,3 x−12=min⁡10⁢x+8,22−x
eqns≔max⁡x,−12+3⁢x=min⁡22−x,10⁢x+8
x=172,x=−89
eqns:=LambertW⁡3⁢x=ln⁡x
eqns≔LambertW⁡3⁢x=ln⁡x
x=ⅇ3
eqns:=RootOf⁡a⁢x2=ⅇx,x=a
eqns≔RootOf⁡a⁢_Z2−ⅇ_Z=a
solve⁡eqns,a
a=−3⁢LambertW⁡−13,a=−3⁢LambertW⁡−1,−13,a=−3⁢LambertW⁡16−I⁢36,a=−3⁢LambertW⁡16+I⁢36
Trigonometric Functions
This particular problem describes the positioning of a simple two-part robot arm. The answer is a little concentrated and has a degree-2 algebraic function.
eq1:=x−l1⁢cos⁡t1+l2⁢cos⁡t1+t2:
eq2:=y−l1⁢sin⁡t1+l2⁢sin⁡t1+t2:
eqns:=eq1,eq2
solve⁡eqns,t1,t2
eqns≔x−l1⁢cos⁡t1−l2⁢cos⁡t1+t2,y−l1⁢sin⁡t1−l2⁢sin⁡t1+t2
t1=arctan⁡−2⁢x⁢RootOf⁡l14−2⁢l12⁢l22+2⁢l12⁢x2−2⁢l12⁢y2+l24−2⁢l22⁢x2−2⁢l22⁢y2+x4+2⁢x2⁢y2+y4+−4⁢l12⁢x+4⁢l22⁢x−4⁢x3−4⁢x⁢y2⁢_Z+4⁢x2+4⁢y2⁢_Z2−l12+l22−x2−y22⁢l1⁢y,RootOf⁡l14−2⁢l12⁢l22+2⁢l12⁢x2−2⁢l12⁢y2+l24−2⁢l22⁢x2−2⁢l22⁢y2+x4+2⁢x2⁢y2+y4+−4⁢l12⁢x+4⁢l22⁢x−4⁢x3−4⁢x⁢y2⁢_Z+4⁢x2+4⁢y2⁢_Z2l1,t2=arctan⁡RootOf⁡l14−2⁢l12⁢l22+2⁢l12⁢x2−2⁢l12⁢y2+l24−2⁢l22⁢x2−2⁢l22⁢y2+x4+2⁢x2⁢y2+y4+−4⁢l12⁢x+4⁢l22⁢x−4⁢x3−4⁢x⁢y2⁢_Z+4⁢x2+4⁢y2⁢_Z2⁢2⁢l12⁢x−2⁢l22⁢x+2⁢x3+2⁢x⁢y2−l14+2⁢l12⁢l22−2⁢l12⁢x2+2⁢l12⁢y2−l24+2⁢l22⁢x2+2⁢l22⁢y2−x4−2⁢x2⁢y2−y44⁢l1⁢y⁢l2⁢RootOf⁡l14−2⁢l12⁢l22+2⁢l12⁢x2−2⁢l12⁢y2+l24−2⁢l22⁢x2−2⁢l22⁢y2+x4+2⁢x2⁢y2+y4+−4⁢l12⁢x+4⁢l22⁢x−4⁢x3−4⁢x⁢y2⁢_Z+4⁢x2+4⁢y2⁢_Z2,−l12−l22+x2+y22⁢l1⁢l2
This problem was posed by H. Melenk.
eqns:=cosx1⋅x3−sinx1⋅x2+5⋅sinx1,−2⋅cosx1+2⋅x32⋅x2+2⋅x23+x2−5,−2⋅sinx1+2⋅x33+2⋅x3⋅x22+x3
eqns≔cos⁡x1⁢x3−sin⁡x1⁢x2+5⁢sin⁡x1,−2⁢sin⁡x1+2⁢x33+2⁢x3⁢x22+x3,−2⁢cos⁡x1+2⁢x32⁢x2+2⁢x23+x2−5
solve⁡eqns,x1,x2,x3
x1=π,x2=1,x3=0,x1=π,x2=RootOf⁡2⁢_Z2+2⁢_Z+3,x3=0,x1=0,x2=RootOf⁡2⁢_Z3+_Z−7,x3=0,x1=arctan⁡21⁢RootOf⁡_Z2+120,−2920,x2=2110,x3=21⁢RootOf⁡_Z2+110
Inverse Trigonometric Functions
The following examples involve inverse trigonometrics, and some were originally proposed by H. Melenk.
eqns≔2⋅arcsinx−arccos3⁢x
eqns≔2⁢arcsin⁡x−arccos⁡3⁢x
x=sin⁡2⁢arctan⁡3⁢22⁢3⁢22+2⁢RootOf⁡12⁢2⁢_Z3+8⁢_Z4−12⁢_Z⁢2+10⁢_Z2−9,index=13
eqns≔2⋅arctanx−arctan2⁢x1−x2
eqns≔2⁢arctan⁡x−arctan⁡2⁢x−x2+1
x=x
eqns:=arccos⁡x−arctan⁡x
eqns≔arccos⁡x−arctan⁡x
x=−2+2⁢52
Equations Requiring Branch Selection
The following examples require branch selection and generally involve ln, radicals, LambertW, inverse trig, and so on.
eqns:=x+x+113=2
eqns≔x+x+113=2
x=−324+12⁢741136+2324+12⁢74113+2
eqns:=x−x−1=3
eqns≔x−x−1=3
eqns:=x+x+x13=3
eqns≔x+x+x13=3
x=1
eqns:=212⋅312⋅612−212⋅612⋅x−212⋅x⋅312+3⋅212⋅x2+x⋅312⋅612−612⋅x2−2⋅x2⋅312+6⋅x3
eqns≔2⁢3⁢6−2⁢6⁢x−2⁢x⁢3+3⁢2⁢x2+x⁢3⁢6−6⁢x2−2⁢x2⁢3+6⁢x3
x=−1,x=612−24+36+12+I⁢72+12⁢2⁢3+6⁢2⁢6−4⁢6⁢3+36⁢2−24⁢3−12⁢612,x=612−24+36+12−I⁢72+12⁢2⁢3+6⁢2⁢6−4⁢6⁢3+36⁢2−24⁢3−12⁢612
eqns:=ln⁡x=75⁢π⁢I11+17
eqns≔ln⁡x=75⁢I⁢π11+17
eqns:=x2⋅ln⁡8−ln⁡x=8
eqns≔x2⁢3⁢ln⁡2−ln⁡x=8
x=8⁢ⅇLambertW⁡−142,x=8⁢ⅇLambertW⁡−1,−142
x=6.690844261,x=2.725891034
Equations Requiring Expansion of Linear Operators
S:=∑i=1na+b⁢ⅇxi−yi2
S≔n⁢a2+∑i=1n⁡−2⁢b⁢ⅇxi⁢yi+2⁢a⁢b⁢ⅇxi+b2⁢ⅇxi2−2⁢a⁢yi+yi2
eqns:=∂∂a⁢S,∂∂b⁢S:
solve⁡eqns,a,b
a=−∑i=1n⁡ⅇxi⁢yi⁢∑i=1n⁡ⅇxi−∑i=1n⁡ⅇxi2⁢∑i=1n⁡yin⁢∑i=1n⁡ⅇxi2−∑i=1n⁡ⅇxi2,b=n⁢∑i=1n⁡ⅇxi⁢yi−∑i=1n⁡ⅇxi⁢∑i=1n⁡yin⁢∑i=1n⁡ⅇxi2−∑i=1n⁡ⅇxi2
The rational solution is found. (Other solutions cannot be expressed in closed form.)
eqns:=1−2⁢arccos⁡x2−x⁢4−x24π=0
eqns≔1−2⁢arccos⁡x2−x⁢−x2+42π=0
x=−2⁢sin⁡RootOf⁡_Z+sin⁡_Z⁢cos⁡_Z2
eqns:=2−sin⁡1−x=2⁢x
eqns≔2+sin⁡x−1=2⁢x
Mixtures of Exponentials, Trigonometrics, and Radicals
The following examples involve solving equations with mixtures of exponential, trigonometrics, radicals, and so on.
eqns:=ⅇRootOf⁡1+_Z2⁢y−x−RootOf⁡1+_Z2⁢−x−1⁢x+112
eqns≔ⅇRootOf⁡_Z2+1⁢y−x−RootOf⁡_Z2+1⁢−x−1⁢x+1
x=ⅇ−I⁢y2+12⁢ⅇ−I⁢y,x=ⅇI⁢y2+12⁢ⅇI⁢y
eqns:=ln⁡x+x−1⁢x+1=y
eqns≔ln⁡x+x−1⁢x+1=y
x=ⅇy2+12⁢ⅇy
eqns:=ln⁡ⅇx+1=2⁢x
eqns≔ln⁡ⅇx+1=2⁢x
x=ln⁡52+12
eqns:=ln⁡ⅇx+1=ln⁡ⅇx−5+ln⁡ⅇx−2
eqns≔ln⁡ⅇx+1=ln⁡ⅇx−5+ln⁡ⅇx−2
solveeqns,x
x=ln⁡4+7
For more information, see the solve help page. See also the help pages on LambertW and on ln.
Return to Index for Example Worksheets
Download Help Document