Solving equations numerically The sign - change rule If the function f(x) is continuous for an interval a x b of its domain, if f(a) and f(b) have opposite signs, then there is at least one root of f(x) = 0 between a and b. Consider an equation f(x) = x 2 -5x + 2 = 0 y x f(0) = 2 f(1) = -2 There is a sign-change This means that there is a solution between x = 0 and x = 1.
Solving equations numerically The sign - change rule Consider an equation f(x) = (2x – 1)(x – 1)(2x – 3) f(0) = -3 f(2) = 3 There is a sign-change x y It is clear from the graph that there are three roots between x = 0 and x = 2
Examples Show that a root of the equation x 3 – 5x – 4 = 0 lies in the interval [2, 3]. f(2) = 2 3 – 5 2 – 4 = 8 – 10 – 4 = - 6 < 0 f(3) = 3 3 – 5 3 – 4 = 27 – 15 – 4 = 8 > 0 There is a change of sign so the root lies in the interval [2, 3] 4.32 is an approximation to a root of the equation xlnx – 2 – x = 0. Check its accuracy to 2 decimal places. f(4.315) = ln4.315 – 2 – = < 0 f(4.325) = ln4.325 – 2 – = > 0 Change of sign, so the root is accurate to 2 decimal places.
Decimal search Consider f(x) = x 3 – 5x – 4 ; f(2) = - 6 and f(3) = 8 f(2.5) = – 5 2.5 – 4 = f(2.6) = – 5 2.6 – 4 = f(2.55) = – 5 2.55 – 4 = For 1 decimal place the root is 2.5 or 2.6 x = 2.5 is ignored so the root must be x = 2.6 for one decimal place. y x
Use decimal search to find each root correct to two decimal places. (i) f(x) = x + (x 3 + 1) - 7 xf(x)sign negative negative negative positive A root lies between 2 and 3 and it is probably closer to negative positive A root lies between 2.6 and 2.7 and it is probably closer to negative positive A root lies between 2.62 and 2.63 and it is probably closer to negative This confirms that the root is 2.63
Use decimal search to find each root correct to two decimal places. (ii) f(x) = x 5 + x xf(x)sign negative negative negative positive A root lies between 4 and negative positive A root lies between 4.5 and positive positive A root lies between 4.52 and negativeThis confirms that the root is negative
Iteration Consider the equation f(x) = x 2 – 5x + 2 = 0 The graph of f(x) shows that one root lies between 0 and 1 and the other root lies between 4 and 5. f(x) x First step is rearrange x 2 – 5x + 2 = 0 in the form x = g(x) Possible rearrangements: x 2 = 5x – 2 x = (5x – 2) 5x = x x = (x 2 + 2)/5 x 2 – 5x = - 2 x(x – 5) = -2 x = 2/(5 – x) x 2 = 5x – 2 x = 5 – 2/x
Graph of rearranged equations x = (5x – 2) x = (x 2 + 2)/5 x = 5 – 2/x x = 2/(5-x)
Using x n+1 = g(x n ) f(x) = x 2 – 5x + 2 = 0 x n+1 = (5x n – 2) Starting value x 0 = 4 x 1 = (5 4 – 2) = x 2 = x 3 = x 4 = x 5 = x 6 = x 7 = x 8 = x 9 = x 10 = x 11 = x 12 = x 13 = x 14 = x 15 = x 16 = root = 4.56 (2 d.p.)
f(x) = x 2 – 5x + 2 = 0 x n+1 = (x n 2 + 2)/5 x 0 = 4 x 1 = x 2 = x 3 = x 4 = x 5 = x 6 = x 7 = x 8 = x 9 = x 10 = x 11 = x n+1 = 2/(5 – x) x 1 = x 0 = 4 x 2 = x 3 = x 4 = x 5 = x 6 = x 7 = x 8 = x n+1 = 5 – 2/x n x 0 = 4 x 2 = x 3 = x 4 = x 5 = x 1 =
x 0 = 4.5 x n+1 = 5 – 2/x n
Example Consider x 3 – 5x – 4 = 0, rearrange in the form x n+1 = f(x n ) x 3 = 5x + 4 Let x 0 = 2 x 1 = x 2 = x 3 = x 4 = x 5 = x 6 = x 7 = x 8 = x 9 = x 10 =
Example Using iteration method formula x n+1 = 2 + ln(x n ), find a root of the equation ln(x) – x + 2 = 0, (correct to 3 s.f.) and starting with x 0 = 2. x 0 = 2 x 1 = x 2 = x 3 = x 4 = x 5 = x 6 = x 7 = x 8 = x 9 = y x So a root is 3.15 (3 s.f.)