Theme 9. Matrix operations in Maple. Systems of linear equations
Site: | Навчально-інформаційний портал НУБіП України |
Course: | Computers and Computer Technology (БЦІ). P2 ☑️ |
Book: | Theme 9. Matrix operations in Maple. Systems of linear equations |
Printed by: | Гість-користувач |
Date: | Tuesday, 13 May 2025, 12:35 AM |
1. Matrix
Matrix (m × n) is a rectangular two-dimensional table that includes rows and columns of elements that can be a number, a variable, a symbol, an expression.
In the matrix, the number a ij is called its elements, the first index denotes the line number, the second is the number of the column, at the intersection of which there is an element (i = 1, 2, ..., m; j = 1,
2, ..., n.
The matrix is called the expression, where
- the number of rows, and - the number of columns of the matrix.
Square matrix - The number of rows is equal to the number of columns.
A single matrix is a square matrix in which the diagonal elements are equal, and all the last ones.
Transposed matrix - columns and rows change cities.
An inverse matrix - a matrix, multiplied by an output matrix, gives a unit matrix.
A matrix is called zero if all its elements are zero.
The matrix that is obtained from the matrix, if all the rows of the matrix are replaced by the corresponding columns, is called transposed .
The square matrix, in which all the elements outside the main diagonal are zero, is called diagonal.
Actions on matrices
The product of a matrix on an arbitrary number is called a matrix whose elements are the product of the matrix elements on:
The sum (difference) of two identical dimensions n matrices is called the matrix, the elements of which are equal to the sum (s) of the corresponding matrix elements, and, that is, for the sum of the matrices and for the difference of the matrices, where the elements of the matrix, the elements of the matrix
The product of the dimension matrix dimension matrix is called the matrix, the elements of which are equal to the sum of the products of the elements of the ith row of the matrix on the corresponding elements of the jth column of the matrix.
The product of the matrices is noncommutative:.
For any matrix there is a single matrix such that the sum of these matrices is equal to the zero matrix:.
The opposite matrix is denoted by.
The difference between two matrices of the same size is a matrix for which equality is true. The difference always exists and equals.
The identifier of a square matrix is called is a number.
2. Systems of linear equations
Many tasks of engineering practice and computational mathematics are reduced to the solution of systems of linear equations. For example, from the field of mechanics, electrical engineering, economics, analytic geometry, interpolation and approximation problems are reduced to finding a solution of systems of linear equations.
Thus, the solution of a two-dimensional system of linear equations is necessary when finding the point of intersection of two straight lines, and the three-dimensional system - when finding the point of intersection of three planes.
A system of linear algebraic equations with variables x1, x2, ... xn is written in the general form (1):
(1)
where: a ij - coefficients of the system; x j - variable; b i - free members; i is the line number, j is the column number.
It can be represented in a matrix form as:
matrix of free members;
desired matrix.
The coefficients of matrices A and B are values of real numbers. If matrix A is not degenerate:
det A¹0,
then such a system has a single solution.
The coefficients of matrices A and B are values of real numbers. If matrix A is not degenerate:
det A¹0,
then such a system has a single solution.
The solution of the system (1) n of equations with n variables is an ordered set of n numbers in a real set, which, when substituting into system (1) instead of x1, x2, ... xn, returns each linear equation of the system in equality. The number of elementary operations in the solution of systems with n variables is proportional to approximately.
Methods for solving the system of linear algebraic equations are divided into direct (exact) and iterative ( approximation). Direct methods are called such methods that allow for a certain number of actions to obtain an exact (in terms of algorithm) solution of the system. Iterative methods are based on the construction of the iterative computational sequence, which coincides with the desired solution. In this case, by performing a certain number of iterations and tearing the process, we can obtain an approximate solution of the system with a predetermined error e.
Methods of solving a system of linear algebraic equations
Direct (exact) |
Iterative (approximate) |
|
|
The most common method for solving systems of linear equations is the Cramer formula, which is used for a system of linear equations with a dimension no more than 4, otherwise the number of computational operations increases according to the law N = (n2-1) n! + N.
The method of sequential exclusion of the desired Gauss is one of the most effective and universal method for solving linear algebraic systems.
The choice of this or that method of solving the system of linear equations is determined by many factors: the peculiarities of the matrix [A], the order of the system n, the nature of the problem to be solved, etc. The table (below) shows the number of operations depending on the method and dimension of the system of equations.
Method |
Cramer |
Gauss |
n = 5 |
2885 |
65 |
n = 10 |
360 * 10 6 |
430 |
All algorithms for solving systems of linear equations are based on elementary operations over matrix elements, i:
- The multiplication of all elements of which is not a string of one and the same number.
- Adding or subtracting items between strings.
- Repositioning strings.
Cramer's Formula
Output data:
- the system of linear equations of the form a ij x j = b i (i = 1, n; j = 1, n) for n <4;
- the determinant D of the matrix a ij (i = 1, n; j = 1, n) º (a ij ) n, n does not equal zero;
It is necessary to find the values of the matrix x i (i = 1, n) º (x i ) n.
The essence of the method . Determine determinants: D - main and D i - auxiliary. Auxiliary determinants are defined for matrices in which each j-column of the matrix (a ij ) n, n is replaced by a matrix - a column (b i ) of n free members. If the headline is zero, then the system is special - the solution may have many options or not have one. If the main determinant is not equal to zero then the coefficients of the sought matrix x i ( i = 1, n) º (x i ) n will be determined by the formula: x i = D i / D, (i = 1, n).
Sequence of calculation:
- Determine the key determinant. If the value of the main determinant is zero, then the "end of the calculation", otherwise go to paragraph 2.
- Identify auxiliary determinants D i and go to step 3.
- Determine the roots of the system of linear equations by the formula: x i = D i / D, (i = 1, n) and proceed to clause 4.
- Output the root value of x i .
Gauss method (sequential exclusion)
Output :
- a system of linear equations of the form Ax = b;
- the determinant of the matrix [A] does not equal zero.
You need to find the value of x i .
The essence of the method . The method of sequential exclusion of the required variables x i (i = 1, n) is one of the most effective and universal methods for solving systems of linear equations. It relates to direct methods and there are several of its schemes, for example, Jordana, one division.
The Gauss solution process consists of two steps. In the first stage (direct motion) system (1) is reduced to a triangular type, and on the second (reverse) - a consistent determination of the desired values of this triangular system is performed.
Matrix method for solving systems of linear equations
A system of linear algebraic equations can be presented in the matrix form:
A • X = B.
If matrix A is not special (| A | ≠ 0), then there exists a matrix A ^ (-1) that is inverse to it. Multiply the matrix equation on the inverse matrix:
A ^ (- 1) · A · X = A ^ (- 1) · B ,
where:
E · X = A ^ (- 1) · B,
or else:
X = A ^ (- 1) · B.
Thus, in order to find the roots of the system of linear equations, we need to calculate the inverse matrix A ^ (- 1) and perform its multiplication by the vector of free coefficients B.
3. LinearAlgebra package matrix operations
The LinearAlgebra package is new and allows you to work with large matrices using approximate calculations from the Numerical Algoritms Group ( NAG ). and in the LinearAlgebra package - on the basis of special Vector () and Matrix () constructors or a short notation <a, b, c> ..
Teams of work with the structure of matrices and vectors:
- rowdim (M) is the number of rows in the matrix M.
- coldim (M) The number of columns of matrix M.
- vectdim (v) number of vector elements v.
- convert (list, vector) transforms the variable type list into a vector.
- row (M, i) of the selection of a-line from the matrix M.
- col (M, i) selection of the i-th column from matrix M.
- CONCAT (M1, M2) M1 and M2 matrices.
Mathematical operations with matrices and vectors:
- add (u, v) or evalm (u + v) adding two vectors or matrices.
- multiply (M1, M2) or evalm (M1 & * M2) the multiplication of matrices M1 and M2.
- dotprod (v1, v2) is the scalar product of vectors v1 and v2.
- crossprod (v1, v2) vector product of vectors v1 and v2.
- angle (v1, v2) calculates the angle between the vectors v1 and v2 of the same length.
- inverse (M) or computation of the inverse to the M matrix.
- det (M) calculating the determinant of the matrix.
- transpose (M) transposition of the matrix.
- linsolve (M, v) solution of the linear system of equations Mx = v.
- gausselim (M) Gauss method for matrix M.
Examples
Matrix task:
with (linalg):
A: = matrix (3.3, [1,4,2,2,1, -2,1,1, -1]); B: = matrix ([[4.6, -2], [6.10, -1], [2,4, -5]]);
Calculating the square of the matrix A (the product of the matrix A itself): evalm (A & * A);
The product of the matrix A on the matrix B : multiply (A, B);
Transposition of the matrix A : transpose (A);
The solution of the system of linear equations in Maple
with (linalg);
eqns: = {x + 5y-z = 1, x + y = 5, x + z = 7}; # setting the system of linear equations
benchmark: = solve (eqns); # system solution
{x = -17/7, y = 18/7, z = 66/7}
subs (bench, eqns); # Checking the solution by substitution in the system - we obtain identities
{7 = 7,5 = 5,1 = 1}
linsolve (A, B); # solution of the system of equations A X = B, where A is a matrix, B is a column of free members
4. Self-checking
- How many parts does the Gauss method come up with?
- What is called reverse matrix?
- Provide an algorithm for constructing an inverse matrix.
- How to find the inverse matrix in MAPLE's mathematical package?
- Give a determinant of the nth order.
- List the properties of determinants.
- In which cases is a determinant equal to zero?
- For which transformations of the determinant elements does the latter not change its meaning?
- What is called an algebraic complement of a determinant element?
- 10. How is Cramer's rule formulated?
Font Face
Font Size
Text Colour
Background Colour
Font Kerning
Image Visibility
Letter Spacing
Line Height
Link Highlight