Linear Simultaneous Equations Chapter 8 Solving Simultaneous Equations Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Review: Linear Simultaneous Equations If equations contain only linear terms of the independent variables – that is, only constants multiplied by each variable – and constants, then the equation is linear If the equation contains any terms such as x2, cos(x), ex, etc., then the equation is non-linear Consider these two linear equations: Engineering Computation: An Introduction Using MATLAB and Excel
Solution to Simultaneous Equations Are there values of x and y that fit both equations? That is, are there values of x and y that simultaneously satisfy both equations? For two equations, it is easy to find the solution by substitution: Write the second equation as: Engineering Computation: An Introduction Using MATLAB and Excel
Solution by Substitution Substitute the second equation into the first: Solve for x: Substitute x into the second equation: Engineering Computation: An Introduction Using MATLAB and Excel
Graphical Solution For equations with two variables, a graphical solution is possible For each equation, plot two points to define a line If the lines intersect, then the intersection point is a solution to both equations Engineering Computation: An Introduction Using MATLAB and Excel
Graphical Solution Equation 1 Equation 2 Engineering Computation: An Introduction Using MATLAB and Excel
Review: Equations in Matrix Form The first step in using matrix methods to solve a series of linear simultaneous equations is to write them in matrix form For n simultaneous equations and n unknowns: where A is the coefficient matrix (n × n); X is the matrix of unknowns (n × 1), and C is the constant matrix (n × 1) Engineering Computation: An Introduction Using MATLAB and Excel
Review: Linear Simultaneous Equations Recall that if there are more unknowns then equations, then we cannot find a unique solution If there are more equations than unknowns, then some equations must be redundant If there are exactly the same number of equations and unknowns, then there may be a unique solution. In this case the coefficient matrix will be square Engineering Computation: An Introduction Using MATLAB and Excel
Solution of System of Linear Equations Multiply both sides of the equation by the inverse of the coefficient matrix. Remember that the order of multiplication is important. Since the inverse of a matrix times that matrix is equal to the identity matrix, Engineering Computation: An Introduction Using MATLAB and Excel
Solution of System of Linear Equations Since the identity matrix times another matrix is equal to that matrix, Therefore, we can find the unknown variables by multiplying the inverse of the coefficient matrix by the constant matrix Engineering Computation: An Introduction Using MATLAB and Excel
Example – 2 Equations Let’s use the matrix approach to solve the equations of the earlier example: The first step is to write the equations in matrix form: Engineering Computation: An Introduction Using MATLAB and Excel
Example – 2 Equations Next, we need to find the inverse of the A matrix: Engineering Computation: An Introduction Using MATLAB and Excel
Example – 2 Equations To find x and y, multiply the inverse of A by C: Engineering Computation: An Introduction Using MATLAB and Excel
MATLAB Solution >> A = [2 3;-4 1]; >> C = [14;28]; >> X = inv(A)*C X = -5 8 >> Engineering Computation: An Introduction Using MATLAB and Excel
Another Example Consider these two equations: MATLAB: >> X = inv(A)*C Warning: Matrix is singular to working precision. X = Inf Engineering Computation: An Introduction Using MATLAB and Excel
What’s Wrong? Solve with substitution: Second equation in terms of y: Substitute into first equation: Engineering Computation: An Introduction Using MATLAB and Excel
What’s Wrong? Solve: Any value of x will satisfy this equation Engineering Computation: An Introduction Using MATLAB and Excel
Graphical Solution Engineering Computation: An Introduction Using MATLAB and Excel
Interpretation of Solution The second equation is equal to the first equation multiplied by a constant Therefore, both equations are the same, as noted by the fact that they define the same line Any point on the line will satisfy both equations Therefore, there are an infinite number of solutions to these equations Engineering Computation: An Introduction Using MATLAB and Excel
A Third Example Consider these two equations: MATLAB: >> X = inv(A)*C Warning: Matrix is singular to working precision. X = Inf Engineering Computation: An Introduction Using MATLAB and Excel
What’s Wrong? Solve with substitution: Second equation in terms of y: Substitute into first equation: Engineering Computation: An Introduction Using MATLAB and Excel
What’s Wrong? Solve: No value of x will satisfy this equation Engineering Computation: An Introduction Using MATLAB and Excel
Graphical Solution Engineering Computation: An Introduction Using MATLAB and Excel
Interpretation of Solution The graphical solution shows that the two equations define parallel lines Since parallel lines never intersect, there is no point that satisfies both equations Therefore, there is no solution to these equations Note that MATLAB (or Excel) solution will result in the same error – the inverse of the coefficient matrix does not exist Engineering Computation: An Introduction Using MATLAB and Excel
Summary If the inverse of the coefficient matrix exists, then there is a solution, and that solution is unique If the inverse does not exist, then there are two possibilities: The equations are incompatible, and so there are no solutions, or At least two of the equations are redundant, and so there are more unknowns than unique equations. Therefore, there are an infinite number of solutions Engineering Computation: An Introduction Using MATLAB and Excel
Example – 3 Equations Write these equations in matrix form: Engineering Computation: An Introduction Using MATLAB and Excel
Example – 3 Equations MATLAB solution: >> C = [-30; 11; 42]; >> X = inv(A)*C X = 7.0000 -2.0000 5.0000 >> Engineering Computation: An Introduction Using MATLAB and Excel
Excel Solution Enter coefficient and constant matrices: Engineering Computation: An Introduction Using MATLAB and Excel
Excel Solution Label and highlight cells for matrix of unknown variables: Engineering Computation: An Introduction Using MATLAB and Excel
Excel Solution Enter formula to invert A matrix and multiply the result by the C matrix. This can be done in two steps or with nested commands as shown here: Engineering Computation: An Introduction Using MATLAB and Excel
Excel Solution Apply formula to the selected array of cells by pressing Ctrl + Shift + Enter: Engineering Computation: An Introduction Using MATLAB and Excel