Previous Up Next

9.3.6  Solving equation(s)

The solve command solves an equation or a system of polynomial equations. In real mode, solve returns only real solutions; to have solve return the complex solutions, switch to complex mode (e.g.by checking the complex box in the CAS configuration, see Section 2.5.5).

The cSolve command is identical to solve, except it returns the complex solutions whether in real mode or complex mode.

With one variable.

solve can solve equations involving a single unknown.

For trigonometric equations, solve returns by default the principal solutions. To have all the solutions, check the All_trig_sol box in the CAS configuration (see Section 2.5.7, item 2.5.7).

Examples

Solve x4−1=3 (in real mode):

solve(x^4-1=3)
     


2
,−
2


          

In complex mode:

solve(x^4-1=3)
     


2
,−
2
,i
2
,−i
2


          

Also (in any mode):

cSolve(x^4-1=3)
     


2
,
2
,−
2
 i,
2
 i

          

Solve ex=2:

solve(exp(x)=2)
     

ln
2

          

Solve cos(2x)=1/2:

solve(cos(2*x)=1/2)
     



π 
6
,
π 
6



          

With the box All_trig_sol checked in CAS configuration:

solve(cos(2*x)=1/2)
     



6π n0
6
,
6π n0−π 
6



          
With several equations and variables.

Examples

Find x,y such that x+y=1 and xy=0:

solve([x+y=1,x-y],[x,y])
     






1
2
,
1
2






          

Find x,y such that x2+y=2 and x+y2=2:

solve([x^2+y=2,x+y^2=2],[x,y])
     







1,1
,
−2,−2
,





5
+1
2
,−


5
+1
2



2



 
+2





,





5
+1
2
,−


5
+1
2



2



 
+2











          

Find x,y,z such that x2y2=0 and x2z2=0:

solve([x^2-y^2=0,x^2-z^2=0],[x,y,z])
     


x,x,x
,
x,−x,−x
,
x,x,−x
,
x,−x,x

          

Find the intersection of a straight line (given by a list of equations) and a plane.

For example, let D be the straight line with cartesian equations [yz=0,zx=0] and let P the plane with equation x−1+y+z=0. Find the intersection of D and P.

solve([[y-z=0,z-x=0],x-1+y+z=0],[x,y,z])
     






1
3
,
1
3
,
1
3






          

Find complex solutions of the system yx2=2, x2y=0:

cSolve([-x^2+y=2,x^2+y],[x,y])
     


i,1
,
i,1

          

Previous Up Next