Analytical Toolbox Simultaneous Equations By Dr J.P.M. Whitty Learning objectives • After the session you will be able to: • • • • Find the solution to two simultaneous equations using graphical means. Algebraic solutions to systems of two equations. Appreciate the solution protocol required for systems of three equations. Use math software to solve systems of equations. 2 Learning Check: Finding the Line • Here’s the StarGate bit: • A point in three dimensions needs six pieces of information to be fully described. • A course therefore seven • Since a line exists essentially in 2D then only two pieces of information. • Two points • A gradient and a point 3 Example Find the equation of the line given that it passes though the points (-2,1) and (6,5) y 1 5 1 Find the Gradient m x 2 6 2 1 Find the intercept y x c 2 1 1 Any point will do 6 (5) c or 1 (2) c 2 2 4 Examples Find the equation of the line given the points (-2,4) and (4,1) expressing your answer in the form ax+by=c. 2. A line has a gradient of –0.75 and passes through a point (3,-4), state the equation of the line. 3. Find the equation of a line with a gradient of unity given that it passes through the point (-1,-2). 1. 5 Learning Check Solve the following using a graphical method y=2x -1 & y= 8-x Hence, use MATLAB to verify your results. Q. Is there a way to solve such problems algebraically? 6 Class Examples Time • Solve the following problems using a • • • • • graphical method (via MATLAB) and verify the results using substitution y=x+3 & y=7-x y=x-4 & 2x+y=5 x+y =3 & y=1-2x y=x+4 & y=3x y=2x-1 & y=3x+2 7 Algebraic Solution One way to obtain an algebraic solution is to • • • • • substitute one equation into the other and obtain the solution of the resulting linear equation. Thus: y=x+3 (1) & y=7-x (2) x+3=7-x 2x=4; x=2 y=x+3=5 Also 7-2=5 (which satisfies the second) 8 Algebraic Solution Continued Solve the following simultaneously x+y =3 & y=1-2x • x+(1-2x)=3 • -1x=2 • x=-2 • -2+y=3; y=5 • Does the other equation fire also? 9 Class Examples Time • Use the method of substitution • y=x-4 & 2x+y=5 • y=x+4 & y=3x • y=2x-1 & y=3x+2 10 Method of Elimination Let us consider the class examples again written in a slightly different form, i.e. equating the variables to a number thus • y-x=-4 & y+2x=5 • y-x=4 & y-3x=0 • y-2x=1 & y-3x=2 • Since in each of these examples that coefficients of y are identical than we are just able to subtract the equations 11 Method of Elimination Write on equation under the other thus y - x=4 y+2x=5 0-3x=-9 x=3; y-3=4; y=1 Does the other equation also fire? 12 Method of Elimination This method can be used when ever the either the x • • • • • or the y coefficients are the same: consider: 3x+y=7 & x+y=3 5x+4y=17 & 3x+4y=15 Additionally if the signs are different we add instead of subtracting 5x-2y=5 & 3x+2y=19 4x+3y=19 & 2x-3y=5 13 Class Examples Time • Solve the following simultaneous equations using the • • • • • method of elimination verity your answers using MATLAB. 2x+y=8 & x-y=1 2x+3y=14 & 2x-y=6 3x+5y=5 & x–5y =15 3x+2y=13 & 3x+y=9 6x+5y=3 & 2x+5y=9 14 Equations with unlike coefficients So far we have only considered sets of equations where the coefficients of either the x or the y values are the same. A problem occurs when this is NOT the case, consider: • 2x+ y= 9 • 5x+2y=22 15 General Method of Ellimination (Cross Multiplication) A. B. C. The method of attack is ALWAYS the same regardless and is as follows: Multiply the first equation by the coefficient of y in the second equation. Multiply the second equation by the coefficient of y in the first equation. The coefficients of y are now equal so they can now be solved as previously. (i.e. if they have the same sign subtract otherwise add) 16 Cross multiplication Let us now consider how this works when applying this to the last example. • 2x+ y= 9 (1) • 5x+2y=22 (2) • 2(2x+ y= 9) (1) • 1(5x+2y=22) (2) 4x+2y=18 (1) 5x+2y=22 (2) -1x+0=-4 x=4 2(4)+y=9 y=1 17 Discussion Examples 1. 2. 3. 4. 5. Use the general method of elimination to solve the following: 2x+y=18 & 2x-3y=1 5x+2y=18 & 7x-8y=9 8x+7y=22 & 12x-5y=2 3x-4y=1 & 9x-7y=13 2x-3y=8 & 8x+15y=5 18 Summary Simultaneous equations can be solve via the method substitution or elimination generally the following rules apply to which method should be used Method of substitution if one of the equations y=mx+c of x=ay+b then substitute this equation into the other. If the equations are both un the form ax+by=c then use the elimination method 19 Solution of three simultaneous equations Problems occur in scientific and engineering problems where more unknowns are required. Hence more equations are required. We will only concern ourselves here with three unknowns as in principle the methods shown in this lecture can easily be extended. 2 I1 3I 2 4 I 3 26 I1 5I 2 3I 3 87 7 I1 2 I 2 6 I 3 12 20 Discussion Examples How would we approach these problems: 1) 3 x 4 y z 10 2 x 3 y 5 z 9 x 2y z 6 2) x yz 4 2 x 3 y 4 z 33 3x 2 y 2 z 2 21 Use of mathematic Software Once you have more than four equations even with the higher math methods of Matrices and Determinates it is still cumbersome and due to the amount of computations errors inevitably creep in to calculation. Thus the need for computer solutions of such systems of equations is self evident. To solve such systems we can use a number of math software packages inc. MatLab & Derive 22 Computer Solutions of Equations Let us consider the systems of equations as before: The solution protocol is the same each time using the math package Go to SOLVE in the top menu 3x 4 y z 10 The package then returns the solution vector for the system #1 #2 2 x 3 y 5 z 9 #3 x 2 y z 6 Select system and enter the appropriate expression numbers (in this case #1,#2 and #3) 23 MatLab Computer Solution 1) Use the following method to 2 I1 3I 2 4 I 3 26 solve the following systems of equations: I1 5I 2 3I 3 87 I. Type each of the coefficients on the RHS into a matrix A=[2, 4, 7 I1 2 I 2 6 I 3 12 -4;1 -5 -3; -7 2 6] (Important to remember the semicolons) 2) II. Type the RHS as a column x yz 4 vector [26; -87; 12] III. Type in x=A\b and the system 2 x 3 y 4 z 33 will return the solution (NB a 3x 2 y 2 z 2 backslash \ is required) 24 Summary • Have we met our learning objectives? • Specifically: are you able to: • Find the solution to two simultaneous equations using graphical means. • Algebraic solutions to systems of two equations. • Appreciate the solution protocol required for systems of three equations. • Use math software to solve systems of equations. 25 Derive Solution of Equations Let us consider the systems of equations as before: The solution protocol is the same each time using the math package Go to SOLVE in the top menu 3x 4 y z 10 The package then returns the solution vector for the system #1 #2 2 x 3 y 5 z 9 #3 x 2 y z 6 Select system and enter the appropriate expression numbers (in this case #1,#2 and #3) 26 Homework 1. 2. 3. Find the equation of the line given the points (-1,6) and (4,1) expressing your answer in the form ax+by=c. A line has a gradient of 1/2 and passes through a point (-2,4), state the equation of the line. Find the equation of a line with a gradient of unity given that it passes through the point (0,-4). 27 Homework 1. 2. 3. 4. 5. Use the most suitable method to solve the following simultaneous equations: 7x-10y=16 & 4x-15y=37 y=3x-1 & 2y-6x=2 3x-5y=13 & 7x+3y=1 3x+5y=5 & x-5y=15 3x+2y=8 & 7x+10y=24 28