Gaussian Elimination in Python
Almost all areas of numerical simulation use linear and polynomial equations. But the field of analysis of linear systems of equations is where they are most naturally used in engineering. Structures, elastic substances, heat fluxes, electromagnetism, electrical circuits, and many more things fall under the general category of linear systems.
When modelling linear systems, mathematical equations of the type Ax = b are generated, wherein x is the input matrix, and b is the response vector of the system. The system's intrinsic properties are reflected in A, called the matrix of coefficients, independent of the input vector. If the input is changed, the linear equation system we want to evaluate will still contain the exact coefficients matrix A but a distinct response vector b.
Methods of Solving Systems of Linear Equations
There are also so-called straightforward approaches along with the iterative procedures, which we won't discuss here. Their attempt to convert the source equations into a system equivalent in properties to the original system that is simpler to solve unites them.
We can use three primary operations to achieve this transformation:
These procedures, of course, have no impact on the system's solutions, which stay unchanged, but they may have an effect on the coefficient matrix A and its determinant.
The three primary direct ways of solutions are compiled in the following table:
Gauss Elimination Method
Row reduction is yet another name for Gaussian elimination. It is a linear algebraic method to resolve a linear system of equations. In essence, a coefficients matrix is subjected to a series of processes. These are the actions that are involved:
These procedures are carried out as long as necessary to fill the lower left side of the coefficient matrix with zeros.
Gauss Elimination Algorithm in Python
Regarding the manual process, there are two possible approaches: one is that the rows are converted by subtraction rather than by summation, and the other is that the converted rows aren't substituted by the initial rows of the matrix A, only the components specific to an upper triangular matrix. In actuality, the computation of solutions is unaffected by elements that do not belong to U (the modified matrix).
3 3 4 -1 5 -2 1 2 -2 1 8 4 1 ['8', '4', '1'] 3 | 4 | -1 | 8 | 5 | -2 | 1 | 4 | 2 | -2 | 1 | 1 | Result: 1 2 3
If we give a set of equations having no solution, the output will be as follows:
3 1 1 1 0 1 -3 2 1 5 2 1 0 ['2', '1', '0'] 1 | 1 | 1 | 2 | 0 | 1 | -3 | 1 | 2 | 1 | 5 | 0 | --------------------------------------------------------------------------- ZeroDivisionError Traceback (most recent call last)
JavaTpoint offers too many high quality services. Mail us on [email protected], to get more information about given services.
JavaTpoint offers college campus training on Core Java, Advance Java, .Net, Android, Hadoop, PHP, Web Technology and Python. Please mail your requirement at [email protected]
Duration: 1 week to 2 week