Section8.5

]>
Book Contents Previous Section 8.4 Computation of Eigenvalues and Eigenvectors Next Section 8.6 Limits Book Index

## 8.5 Solution of Linear and Polynomial Equations

In this section we discuss the Axiom facilities for solving systems of linear equations, finding the roots of polynomials and linear equation solving systems of polynomial equations. For a discussion of the solution of differential equations, see ugProblemDEQ .

### 8.5.1 Solution of Systems of Linear Equations

You can use the operation solve to solve systems of linear equations. equation:linear:solving

The operation solve takes two arguments, the list of equations and the list of the unknowns to be solved for. A system of linear equations need not have a unique solution.

To solve the linear system: x+y+z=8 3 x-2 y+z=0 x+2 y+2 z=17 evaluate this expression.

solve([x+y+z=8,3*x-2*y+z=0,x+2*y+2*z=17],[x,y,z])

[[x=-1, y=2, z=7]]

Type: List List Equation Fraction Polynomial Integer

Parameters are given as new variables starting with a percent sign and % and the variables are expressed in terms of the parameters. If the system has no solutions then the empty list is returned.

When you solve the linear system x+2 y+3 z=2 2 x+3 y+4 z=2 3 x+4 y+5 z=2 with this expression you get a solution involving a parameter.

solve([x+2*y+3*z=2,2*x+3*y+4*z=2,3*x+4*y+5*z=2],[x,y,z])

[[x=%Q-2, y=-2%Q+2, z=%Q]]

Type: List List Equation Fraction Polynomial Integer

The system can also be presented as a matrix and a vector. The matrix contains the coefficients of the linear equations and the vector contains the numbers appearing on the right-hand sides of the equations. You may input the matrix as a list of rows and the vector as a list of its elements.

To solve the system: x+y+z=8 3 x-2 y+z=0 x+2 y+2 z=17 in matrix form you would evaluate this expression.

solve([ [1,1,1],[3,-2,1],[1,2,2] ],[8,0,17])

[particular=[-1, 2, 7],basis=[[0, 0, 0]]]

Type: Record(particular: Union(Vector Fraction Integer,"failed"), basis: List Vector Fraction Integer)

The solutions are presented as a Record with two components: the component particular contains a particular solution of the given system or the item "failed" if there are no solutions, the component basis contains a list of vectors that are a basis for the space of solutions of the corresponding homogeneous system. If the system of linear equations does not have a unique solution, then the basis component contains non-trivial vectors.

This happens when you solve the linear system x+2 y+3 z=2 2 x+3 y+4 z=2 3 x+4 y+5 z=2 with this command.

solve([ [1,2,3],[2,3,4],[3,4,5] ],[2,2,2])

[particular=[-2, 2, 0],basis=[[1,-2, 1]]]

Type: Record(particular: Union(Vector Fraction Integer,"failed"), basis: List Vector Fraction Integer)

All solutions of this system are obtained by adding the particular solution with a linear combination of the basis vectors.

When no solution exists then "failed" is returned as the particular component, as follows:

solve([ [1,2,3],[2,3,4],[3,4,5] ],[2,3,2])

[particular="failed",basis=[[1,-2, 1]]]

Type: Record(particular: Union(Vector Fraction Integer,"failed"), basis: List Vector Fraction Integer)

When you want to solve a system of homogeneous equations (that is, a system where the numbers on the right-hand sides of the nullspace equations are all zero) in the matrix form you can omit the second argument and use the nullSpace operation.

This computes the solutions of the following system of equations: x+2 y+3 z=0 2 x+3 y+4 z=0 3 x+4 y+5 z=0 The result is given as a list of vectors and these vectors form a basis for the solution space.

nullSpace([ [1,2,3],[2,3,4],[3,4,5] ])

[[1,-2, 1]]

Type: List Vector Integer

### 8.5.2 Solution of a Single Polynomial Equation

Axiom can solve polynomial equations producing either approximate polynomial:root finding or exact solutions. equation:polynomial:solving Exact solutions are either members of the ground field or can be presented symbolically as roots of irreducible polynomials.

This returns the one rational root along with an irreducible polynomial describing the other solutions.

solve(x**3 = 8,x)

[x=2, x 2+2 x+4=0]

Type: List Equation Fraction Polynomial Integer

If you want solutions expressed in terms of radicals you would use this instead. radical

radicalSolve(x**3 = 8,x)

[x=--3-1, x=-3-1, x=2]

Type: List Equation Expression Integer

The solve command always returns a value but radicalSolve returns only the solutions that it is able to express in terms of radicals. radical

If the polynomial equation has rational coefficients you can ask for approximations to its real roots by calling solve with a second argument that specifies the ``precision'' precision . This means that each approximation will be within of the actual result.

Notice that the type of second argument controls the type of the result.

solve(x**4 - 10*x**3 + 35*x**2 - 50*x + 25,.0001)

[x=3. 6180114746 09375, x=1. 3819885253 90625]

Type: List Equation Polynomial Float

If you give a floating-point precision you get a floating-point result; if you give the precision as a rational number you get a rational result.

solve(x**3-2,1/1000)

[x=2581 2048]

Type: List Equation Polynomial Fraction Integer

If you want approximate complex results you should use the approximation command complexSolve that takes the same precision argument .

complexSolve(x**3-2,.0001)

[x=1. 2599182128 90625, x=-0. 6298943279 5395613131-1. 0910949707 03125 i, x=-0. 6298943279 5395613131+1. 0910949707 03125 i]

Type: List Equation Polynomial Complex Float

Each approximation will be within of the actual result in each of the real and imaginary parts.

complexSolve(x**2-2*%i+1,1/100)

[x=-13028925 16777216-325 256 i, x=13028925 16777216+325 256 i]

Type: List Equation Polynomial Complex Fraction Integer

Note that if you omit the = from the first argument Axiom generates an equation by equating the first argument to zero. Also, when only one variable is present in the equation, you do not need to specify the variable to be solved for, that is, you can omit the second argument.

Axiom can also solve equations involving rational functions. Solutions where the denominator vanishes are discarded.

radicalSolve(1/x**3 + 1/x**2 + 1/x = 0,x)

[x=--3-1 2, x=-3-1 2]

Type: List Equation Expression Integer

### 8.5.3 Solution of Systems of Polynomial Equations

Given a system of equations of rational functions with exact coefficients: equation:polynomial:solving

p 1(x 1,…,x n)⋮p m(x 1,…,x n)

Axiom can find numeric or symbolic solutions. The system is first split into irreducible components, then for each component, a triangular system of equations is found that reduces the problem to sequential solution of univariate polynomials resulting from substitution of partial solutions from the previous stage. q 1(x 1,…,x n)⋮q m(x n)

Symbolic solutions can be presented using ``implicit'' algebraic numbers defined as roots of irreducible polynomials or in terms of radicals. Axiom can also find approximations to the real or complex roots of a system of polynomial equations to any user-specified accuracy.

The operation solve for systems is used in a way similar to solve for single equations. Instead of a polynomial equation, one has to give a list of equations and instead of a single variable to solve for, a list of variables. For solutions of single equations see ugxProblemOnePol .

Use the operation solve if you want implicitly presented solutions.

solve([3*x**3 + y + 1,y**2 -4],[x,y])

[[x=-1, y=2],[x 2-x+1=0, y=2],[3 x 3-1=0, y=-2]]

Type: List List Equation Fraction Polynomial Integer
solve([x = y**2-19,y = z**2+x+3,z = 3*x],[x,y,z])

[[x=z 3, y=3 z 2+z+9 3, 9 z 4+6 z 3+55 z 2+15 z-90=0]]

Type: List List Equation Fraction Polynomial Integer

Use radicalSolve if you want your solutions expressed in terms of radicals.

radicalSolve([3*x**3 + y + 1,y**2 -4],[x,y])

[[x=-3+1 2, y=2],[x=--3+1 2, y=2],[x=--1 3-1 2 3 3, y=-2],[x=-1 3-1 2 3 3, y=-2],[x=1 3 3, y=-2],[x=-1, y=2]]

Type: List List Equation Expression Integer

To get numeric solutions you only need to give the list of equations and the precision desired. The list of variables would be redundant information since there can be no parameters for the numerical solver.

If the precision is expressed as a floating-point number you get results expressed as floats.

solve([x**2*y - 1,x*y**2 - 2],.01)

[[y=1. 5859375, x=0. 79296875]]

Type: List List Equation Polynomial Float

To get complex numeric solutions, use the operation complexSolve, which takes the same arguments as in the real case.

complexSolve([x**2*y - 1,x*y**2 - 2],1/1000)

[[y=1625 1024, x=1625 2048],[y=-435445573689 549755813888-1407 1024 i, x=-435445573689 1099511627776-1407 2048 i],[y=-435445573689 549755813888+1407 1024 i, x=-435445573689 1099511627776+1407 2048 i]]

Type: List List Equation Polynomial Complex Fraction Integer

It is also possible to solve systems of equations in rational functions over the rational numbers. Note that [x=0. 0, a=0. 0] is not returned as a solution since the denominator vanishes there.

solve([x**2/a = a,a = a*x],.001)

[[x=1. 0, a=-1. 0],[x=1. 0, a=1. 0]]

Type: List List Equation Polynomial Float

When solving equations with denominators, all solutions where the denominator vanishes are discarded.

radicalSolve([x**2/a + a + y**3 - 1,a*y + a + 1],[x,y])

[[x=--a 4+2 a 3+3 a 2+3 a+1 a 2, y=-a-1 a],[x=-a 4+2 a 3+3 a 2+3 a+1 a 2, y=-a-1 a]]

Type: List List Equation Expression Integer
Book Contents Previous Section 8.4 Computation of Eigenvalues and Eigenvectors Next Section 8.6 Limits Book Index