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.
-
solve takes one mandatory argument and one optional
argument:
-
eqn, an equation or expression assumed to be zero.
- Optionally, x, a variable (by default, x=x).
- solve(eqn,x) returns the solution
to the equation.
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):
In complex mode:
Also (in any mode):
Solve ex=2:
Solve cos(2x)=1/2:
With the box All_trig_sol checked in CAS configuration:
With several equations and variables.
-
solve takes one mandatory argument and one optional
argument:
-
eqns, a list of polynomial equations.
- vars, a list of variables.
- solve(eqns,vars) returns the
solutions to the system of equations.
Examples
Find x,y such that x+y=1 and x−y=0:
|
| ⎡
⎢
⎢
⎣ | ⎡
⎢
⎢
⎣ | | , | | ⎤
⎥
⎥
⎦ | ⎤
⎥
⎥
⎦ |
| | | | | | | | | | |
|
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 | ⎤
⎦ | , | ⎡
⎢
⎢
⎢
⎢
⎢
⎣ | | ,− | ⎛
⎜
⎜
⎝ | | ⎞
⎟
⎟
⎠ | | +2 | ⎤
⎥
⎥
⎥
⎥
⎥
⎦ | , | ⎡
⎢
⎢
⎢
⎢
⎢
⎣ | | ,− | ⎛
⎜
⎜
⎝ | | ⎞
⎟
⎟
⎠ | | +2 | ⎤
⎥
⎥
⎥
⎥
⎥
⎦ | ⎤
⎥
⎥
⎥
⎥
⎥
⎦ |
| | | | | | | | | | |
|
Find x,y,z such that x2−y2=0 and x2−z2=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
[y−z=0,z−x=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]) |
|
| ⎡
⎢
⎢
⎣ | ⎡
⎢
⎢
⎣ | | , | | , | | ⎤
⎥
⎥
⎦ | ⎤
⎥
⎥
⎦ |
| | | | | | | | | | |
|
Find complex solutions of the system y−x2=2, x2y=0:
cSolve([-x^2+y=2,x^2+y],[x,y]) |
|
| ⎡
⎣ | ⎡
⎣ | −i,1 | ⎤
⎦ | , | ⎡
⎣ | i,1 | ⎤
⎦ | ⎤
⎦ |
| | | | | | | | | | |
|