Maxima Function
solve (expr, x)
solve(expr)
solve([eqn_1,...,eqn_n],[x_1,...,x_n])
Solves the algebraic equation expr for the variable
x and returns a list of solution equations in x. If expr is not an
equation, the equation expr = 0
is assumed in its place.
x may be a function (e.g. f(x)
), or other non-atomic expression
except a sum or product. x may be omitted if expr contains only one
variable. expr may be a rational expression, and may contain
trigonometric functions, exponentials, etc.
The following method is used:
Let E be the expression and X be the variable. If E is linear in X
then it is trivially solved for X. Otherwise if E is of the form
A*X^N + B
then the result is (-B/A)^1/N)
times the N
'th roots of
unity.
If E is not linear in X then the gcd of the exponents of X in E (say
N) is divided into the exponents and the multiplicity of the roots is
multiplied by N. Then solve
is called again on the result.
If E factors then solve
is called on each of the factors. Finally
solve
will use the quadratic, cubic, or quartic formulas where
necessary.
In the case where E is a polynomial in some function of the variable
to be solved for, say F(X)
, then it is first solved for F(X)
(call the
result C), then the equation F(X)=C
can be solved for X provided the
inverse of the function F is known.
breakup
if false
will cause solve
to express the solutions of
cubic or quartic equations as single expressions rather than as made
up of several common subexpressions which is the default.
multiplicities
- will be set to a list of the multiplicities of
the individual solutions returned by solve
, realroots
, or allroots
.
Try apropos (solve)
for the switches which affect solve
. describe
may
then by used on the individual switch names if their purpose is not
clear.
solve ([eqn_1, ..., eqn_n], [x_1, ..., x_n])
solves a system of simultaneous
(linear or non-linear) polynomial equations by calling linsolve
or
algsys
and returns a list of the solution lists in the variables. In
the case of linsolve
this list would contain a single list of
solutions. It takes two lists as arguments. The first list
represents the equations to be solved; the second list is a
list of the unknowns to be determined. If the total number of
variables in the equations is equal to the number of equations, the
second argument-list may be omitted. For linear systems if the given
equations are not compatible, the message inconsistent
will be
displayed (see the switch); if no unique
solution exists, then singular
will be displayed.
When programmode
is false
,
solve
displays solutions with intermediate expression (%t
) labels,
and returns the list of labels.
When globalsolve
is true
and the problem is to solve two or more linear equations,
each solved-for variable is bound to its value in the solution of the equations.
Examples:
(%i1) solve (asin (cos (3*x))*(f(x) - 1), x); SOLVE is using arc-trig functions to get a solution. Some solutions will be lost. %pi (%o1) [x = ---, f(x) = 1] 6 (%i2) ev (solve (5^f(x) = 125, f(x)), solveradcan); log(125) (%o2) [f(x) = --------] log(5) (%i3) [4*x^2 - y^2 = 12, x*y - x = 2]; 2 2 (%o3) [4 x - y = 12, x y - x = 2] (%i4) solve (%, [x, y]); (%o4) [[x = 2, y = 2], [x = .5202594388652008 %i - .1331240357358706, y = .0767837852378778 - 3.608003221870287 %i], [x = - .5202594388652008 %i - .1331240357358706, y = 3.608003221870287 %i + .0767837852378778], [x = - 1.733751846381093, y = - .1535675710019696]] (%i5) solve (1 + a*x + x^3, x); 3 sqrt(3) %i 1 sqrt(4 a + 27) 1 1/3 (%o5) [x = (- ---------- - -) (--------------- - -) 2 2 6 sqrt(3) 2 sqrt(3) %i 1 (---------- - -) a 2 2 - --------------------------, x = 3 sqrt(4 a + 27) 1 1/3 3 (--------------- - -) 6 sqrt(3) 2 3 sqrt(3) %i 1 sqrt(4 a + 27) 1 1/3 (---------- - -) (--------------- - -) 2 2 6 sqrt(3) 2 sqrt(3) %i 1 (- ---------- - -) a 2 2 - --------------------------, x = 3 sqrt(4 a + 27) 1 1/3 3 (--------------- - -) 6 sqrt(3) 2 3 sqrt(4 a + 27) 1 1/3 a (--------------- - -) - --------------------------] 6 sqrt(3) 2 3 sqrt(4 a + 27) 1 1/3 3 (--------------- - -) 6 sqrt(3) 2 (%i6) solve (x^3 - 1); sqrt(3) %i - 1 sqrt(3) %i + 1 (%o6) [x = --------------, x = - --------------, x = 1] 2 2 (%i7) solve (x^6 - 1); sqrt(3) %i + 1 sqrt(3) %i - 1 (%o7) [x = --------------, x = --------------, x = - 1, 2 2 sqrt(3) %i + 1 sqrt(3) %i - 1 x = - --------------, x = - --------------, x = 1] 2 2 (%i8) ev (x^6 - 1, %[1]); 6 (sqrt(3) %i + 1) (%o8) ----------------- - 1 64 (%i9) expand (%); (%o9) 0 (%i10) x^2 - 1; 2 (%o10) x - 1 (%i11) solve (%, x); (%o11) [x = - 1, x = 1] (%i12) ev (%th(2), %[1]); (%o12) 0