Presentation is loading. Please wait.

Presentation is loading. Please wait.

Root-Finding Algorithm Bisection method Suppose we want to solve the equation f(x) = 0. Given two points a and b such that f(a) and f(b) have opposite.

Similar presentations


Presentation on theme: "Root-Finding Algorithm Bisection method Suppose we want to solve the equation f(x) = 0. Given two points a and b such that f(a) and f(b) have opposite."— Presentation transcript:

1 Root-Finding Algorithm Bisection method Suppose we want to solve the equation f(x) = 0. Given two points a and b such that f(a) and f(b) have opposite signs, we know by the intermediate value theorem that f must have at least one root in the interval [a, b] as long as f is continuous

2 Root-Finding Algorithm The bisection method divides the interval in two by computing c = (a+b) / 2. There are now two possibilities: either f(a) and f(c) have opposite signs, or f(c) and f(b) have opposite signs. The bisection algorithm is then applied to the sub-interval where the sign change occurs, meaning that the bisection algorithm is inherently recursive.

3 Root-Finding Algorithm The bisection method is less efficient than Newton's method but it is much less prone to odd behavior.

4 Root-Finding Algorithm 'Bisection Method ‘ Start loop Do While (abs(xR - xL)) > epsilon xM = (xR + xL) / 2 'Calculate midpoint of domain 'Find f(xM) If ((f(xL) * f(xM)) > 0) Then 'Throw away left half xL = xM Else 'Throw away right half xR = xM End If Loop

5 Root-Finding Algorithm 假設函數 f 在 [a,b] 之間連續,且 f(a) 與 f(b) 異號時,二分法可依指定的精確度求 f(x) = 0 的一個近似解。

6 Root-Finding Algorithm 由於 (a+b)/2 有可能造成所得結果落在 [a,b] 區間外 (見以下範例),故應採用 a + (b-a)/2 較佳。 以 3-digit chopping 為例: a = 0.982 b = 0.987 (a+b)/2 = (0.982+0.987) / 2 = 1.96 / 2 = 0.980 a+(b-a)/2 = 0.982 + 0.00500/2 = 0.982 + 0.00250 = 0.984

7 Root-Finding Algorithm Newton's method Suppose f : [a, b] → R is a differentiable function defined on the interval [a, b] with values in the real numbers R.

8 Root-Finding Algorithm

9 Secant method The secant method is defined by the recurrence relation As can be seen from the recurrence relation, the secant method requires two initial values, x0 and x1, which should ideally be chosen to lie close to the root.

10 Root-Finding Algorithm

11 The secant method does not require that the root remain bracketed like the bisection method does, and hence it does not always converge. The false position method uses the same formula as the secant method. However, it does not apply the formula on x n−1 and x n, like the secant method, but on x n and on the last iterate x k such that f(x k ) and f(x n ) have a different sign. This means that the false position method always converges.

12 Root-Finding Algorithm False position method Like the bisection method, the false position method starts two points a 0 and b 0 such that f(a 0 ) and f(b 0 ) are of opposite signs, which implies by the intermediate value theorem that the function f has a root in the interval [a 0, b 0 ]. The method proceeds by producing a sequence of shrinking intervals [a k, b k ] that all contain a root of f.

13 Root-Finding Algorithm At iteration number k, the number is computed. As explained below, c k is the root of the secant line through (a k, f(a k )) and (b k, f(b k )).

14 Root-Finding Algorithm If f(a k ) and f(c k ) have the same sign, then we set a k+1 = c k and b k+1 = b k, otherwise we set a k+1 = a k and b k+1 = c k. This process is repeated until the root is approximated sufficiently well.

15 Root-Finding Algorithm

16


Download ppt "Root-Finding Algorithm Bisection method Suppose we want to solve the equation f(x) = 0. Given two points a and b such that f(a) and f(b) have opposite."

Similar presentations


Ads by Google