Mada za sehemu hiiNumerical MethodMada 4
- Errors
- Roots By Iterative Methods
- Numerical Integration
- Simpson's Rule
A root of a function f(x) is a value of x for which f(x)=0. Solving an equation means finding all its roots. While linear and quadratic equations have direct solutions, higher-degree equations and other functions often require iterative numerical approximations.
An iterative method uses an initial guess to generate a sequence of improved approximations that converge to the exact solution.
The Newton-Raphson method is a powerful numerical technique for finding roots based on linear approximation. It uses an initial guess x0 to approximate the solution of f(x)=0.
Derivation
Let c be the exact root (f(c)=0) and x0 be an initial estimate. The Newton-Raphson formula for a new estimate x1 is derived by constructing the tangent to f(x) at the point P(x0,f(x0)).
The slope of the tangent line at P is given by the derivative f′(x0). From the geometry of the tangent line, we also have:
f′(x0)=x0−x1f(x0)−0=x0−x1f(x0)
Rearranging this equation to solve for x1:
x0−x1=f′(x0)f(x0)
x1=x0−f′(x0)f(x0)
Repeating this process using x1 as the new initial approximation gives:
x2=x1−f′(x1)f(x1)
In general, the Newton-Raphson formula is:
xn+1=xn−f′(xn)f(xn)(8.1)
This formula iteratively improves the estimate until xn converges to the exact root c.
The Newton-Raphson method generally assumes that there is an interval [a,b] where f(a) and f(b) have opposite signs (f(a)⋅f(b)<0), indicating a root exists within the interval.
Example 1
Use the Newton-Raphson method to perform three iterations to approximate the root of f(x)=x2−2x−1 in the interval [2,3], starting with x0=2, correct to three decimal places.
Solution:
f(x)=x2−2x−1
f′(x)=2x−2
Check for root in the interval:
f(2)=22−2(2)−1=−1
f(3)=32−2(3)−1=2
Since f(2)f(3)<0, a root exists in [2,3].
Newton-Raphson formula: xn+1=xn−f′(xn)f(xn)
Iteration 1:
x1=x0−f′(x0)f(x0)=2−f′(2)f(2)=2−2−1=2.5
Iteration 2:
x2=x1−f′(x1)f(x1)=2.5−f′(2.5)f(2.5)=2.5−30.25≈2.416667
Iteration 3:
x3=x2−f′(x2)f(x2)≈2.416667−f′(2.416667)f(2.416667)≈2.416667−2.8333340.006944≈2.414214
Thus, x3≈2.414 (correct to three decimal places).
Example 2
If f(x)=cos(x)sin(x)−1, show that the Newton-Raphson method leads to the recurrence formula xn+1=xn+cos(xn).
Solution:
f(x)=cos(x)sin(x)−1
Using the quotient rule:
f′(x)=cos2(x)cos(x)cos(x)−(sin(x)−1)(−sin(x))=cos2(x)cos2(x)+sin2(x)−sin(x)=cos2(x)1−sin(x)
Newton-Raphson formula:
xn+1=xn−f′(xn)f(xn)=xn−cos2(xn)1−sin(xn)cos(xn)sin(xn)−1=xn−cos(xn)sin(xn)−1⋅1−sin(xn)cos2(xn)=xn+cos(xn)
Example 3
Use the Newton-Raphson method to estimate the real root of f(x)=x3+2x2+8x+3=0. Perform two iterations, starting with x0=0, correct to three decimal places.
Solution:
f(x)=x3+2x2+8x+3
f′(x)=3x2+4x+8
Iteration 1:
x1=x0−f′(x0)f(x0)=0−83=−0.375
Iteration 2:
x2=x1−f′(x1)f(x1)=−0.375−f′(−0.375)f(−0.375)=−0.375−−0.3125+8−0.08789≈−0.375−7.6875−0.08789≈−0.3635
or −0.364 to 3 d.p.
Example 4
Starting with x0=1, find the solution of f(x)=x−cos(x)=0 in the interval [0,2π] using the Newton-Raphson method, correct to six decimal places.
Solution:
f(x)=x−cos(x)
f′(x)=1+sin(x)
Newton-Raphson formula: xn+1=xn−1+sin(xn)xn−cos(xn)
Iteration 1: x1=1−1+sin(1)1−cos(1)≈0.750364
Iteration 2: x2≈0.739113
Iteration 3: x3≈0.739085
Iteration 4: x4≈0.739085
The solution is approximately 0.739085.
The Newton-Raphson formula can be used to estimate the nth root and reciprocal of a number.
The rth root of a positive number
Let x=rN, which implies xr=N or xr−N=0. We can define a function f(x)=xr−N.
The general form is f(xn)=xnr−N (8.2)
Differentiating (8.2) gives f′(xn)=rxnr−1 (8.3)
Substituting (8.2) and (8.3) into the Newton-Raphson formula xn+1=xn−f′(xn)f(xn):
xn+1=xn−rxnr−1xnr−N=xn−rxnr−1xnr+rxnr−1N=xn−rxn+rxnr−1N=rrxn−rxn+rxnr−1N
xn+1=r(r−1)xn+xnr−1N=r1((r−1)xn+xnr−1N)
Therefore, the rth root of a positive number N is given by:
xn+1=r1((r−1)xn+xnr−1N)for r≥2.
Example 1: Square root of 8
Show that the iterative formula xn+1=21(xn+xnN) can be used to approximate the square root of N. Then, perform 3 iterations starting with x0=2.5 to approximate 8.
Solution:
For the square root, r=2. Substituting into the general formula:
xn+1=21((2−1)xn+xn2−1N)=21(xn+xnN)
Now, with N=8 and x0=2.5:
Iteration 1: x1=21(2.5+2.58)=21(2.5+3.2)=2.85
Iteration 2: x2=21(2.85+2.858)≈21(2.85+2.8070)≈2.8285
Iteration 3: x3=21(2.8285+2.82858)≈21(2.8285+2.8284)≈2.82845≈2.8284
Therefore, 8≈2.8284.
Example 2: Cube root of 10
Use the Newton-Raphson method to find the cube root of 10 starting with x0=2 by performing 4 iterations.
Solution:
xn+1=31(2xn+xn210)
Iteration 1: x1=31(2(2)+2210)=31(4+2.5)=36.5≈2.16667
Iteration 2: x2=31(2(2.16667)+2.16667210)≈31(4.33334+2.126)≈2.1531 or 2.153
Iteration 3: x3≈31(2(2.153)+2.153210)≈2.15443
Iteration 4: x4≈31(2(2.15443)+2.15443210)≈2.15443 or 2.154
Therefore, 310≈2.1544.
Example 3: 5th root of 99
Use the Newton-Raphson method to find the 5th root of 99 starting with x0=2 by performing 5 iterations.
Solution:
xn+1=51(4xn+xn499)
Iteration 1: x1=51(4(2)+2499)=51(8+6.1875)≈2.8375
Iteration 2: x2≈51(4(2.8375)+2.8375499)≈2.5754 or 2.575
Iteration 3: x3≈51(4(2.575)+2.575499)≈2.5104 or 2.51
Iteration 4: x4≈51(4(2.51)+2.51499)≈2.5069 or 2.507
Iteration 5: x5≈51(4(2.507)+2.507499)≈2.5068 or 2.507
Therefore, 599≈2.5068.
Finding the reciprocal of a number using the Newton-Raphson formula
If N is a non-zero number, its reciprocal is N1. If x is an approximation of the reciprocal, then x≈N1, or Nx≈1, which can be written as f(x)=Nx−1=0.
The general formula is f(xn)=Nxn−1 (8.4)
Differentiating (8.4) with respect to x:
f′(xn)=N(8.5)
Substituting (8.4) and (8.5) into the Newton-Raphson formula xn+1=xn−f′(xn)f(xn):
xn+1=xn−NNxn−1=xn−xn+N1=N1
This derivation is incorrect and does not give an iterative formula.
The correct derivation is as follows. We want to find the reciprocal of N, so we consider the function f(x)=x1−N. Then f′(x)=−x21. Applying the Newton-Raphson method:
xn+1=xn−−xn21xn1−N=xn+xn2(xn1−N)=xn+xn−Nxn2=2xn−Nxn2=xn(2−Nxn)
Thus, the correct iterative formula is:
xn+1=xn(2−Nxn)
Example 1: Reciprocal of 2.5
Use the Newton-Raphson method to find the reciprocal of 2.5 starting with x0=0.3 by performing 3 iterations.
Solution:
N=2.5, x0=0.3
Formula: xn+1=xn(2−2.5xn)
Iteration 1: x1=0.3(2−2.5×0.3)=0.3(2−0.75)=0.3(1.25)=0.375
Iteration 2: x2=0.375(2−2.5×0.375)=0.375(2−0.9375)=0.375(1.0625)=0.3984375
Iteration 3: x3=0.3984375(2−2.5×0.3984375)=0.3984375(2−0.99609375)=0.3984375(1.00390625)≈0.4000 or 0.4
The approximate reciprocal of 2.5 is 0.4.
Example 2: Reciprocal of 719
Use the Newton-Raphson method to find the reciprocal of 719 by performing five iterations using x0=2 as an initial guess.
Solution:
N=719≈2.714286, x0=2
Formula: xn+1=xn(2−719xn)
Iteration 1: x1=2(2−719×2)=2(2−5.42857)=−6.85714
This is incorrect, the initial guess is too far from the actual reciprocal which is 197≈0.3684. We will use an initial guess of 0.3.
Using x0=0.3:
Iteration 1: x1=0.3(2−719×0.3)=0.3(2−0.814286)=0.355714 or 0.356
Iteration 2: x2=0.356(2−719×0.356)≈0.3678 or 0.368
Iteration 3: x3≈0.3684 or 0.368
Iteration 4: x4≈0.3684 or 0.368
Iteration 5: x5≈0.3684 or 0.368
The reciprocal of 719 is 197≈0.3684.
The secant method is similar to the Newton-Raphson method but uses two initial values and approximates the derivative using a finite difference (the slope of the secant line). The root is approximated using the secant line through two points.
The slope of the secant line through points A(xn−1,f(xn−1)) and B(xn,f(xn)) approximates the derivative at xn:
f′(xn)≈xn−xn−1f(xn)−f(xn−1)(8.6)
Substituting (8.6) into the Newton-Raphson formula xn+1=xn−f′(xn)f(xn) gives the secant formula:
xn+1=xn−xn−xn−1f(xn)−f(xn−1)f(xn)=xn−f(xn)f(xn)−f(xn−1)xn−xn−1
for n=1,2,3,…
Example 1
Using the secant formula with x0=1.5 and x1=1, find the root of the function f(x)=x2−2=0 to four decimal places by performing 3 iterations.
Solution:
f(x)=x2−2
Iteration 1 (n=1):
x2=x1−f(x1)f(x1)−f(x0)x1−x0=1−(−1)−1−0.251−1.5=1−(−1)−1.25−0.5=1−0.4=1.4
Iteration 2 (n=2):
x3=x2−f(x2)f(x2)−f(x1)x2−x1=1.4−(1.42−2)(1.42−2)−(−1)1.4−1=1.4−(1.96−2)−0.04+10.4=1.4−(−0.04)0.960.4=1.4+0.960.016≈1.4+0.016667≈1.4167
Iteration 3 (n=3):
x4=x3−f(x3)f(x3)−f(x2)x3−x2=1.4167−(1.41672−2)(1.41672−2)−(1.42−2)1.4167−1.4≈1.4167−(0.0070)0.0070−(−0.04)0.0167≈1.4167−(0.0070)0.04700.0167≈1.4167−0.0025≈1.4142
The root is approximately 1.4142.
Example 2
Use the secant method to estimate the root of f(x)=e−x−x. Perform 3 iterations with initial estimates of x0=0 and x1=1. In each iteration, find the percentage relative error if the true root is 0.56714329.
Solution:
f(x)=e−x−x
Iteration 1 (n=1):
x2=1−(e−1−1)(e−1−1)−(e0−0)1−0=1−(0.36788−1)0.36788−1−11=1−−1.63212−0.63212≈1−0.3873=0.6127
Percentage relative error: 0.56714329∣0.56714329−0.6127∣×100%≈8.03%
Iteration 2 (n=2):
x3=0.6127−(e−0.6127−0.6127)(e−0.6127−0.6127)−(e−1−1)0.6127−1≈0.6127−(0.5428−0.6127)0.5428−0.6127−0.3678+1−0.3873≈0.6127−(−0.0699)0.5623−0.3873≈0.6127−0.0481≈0.5646
Percentage relative error: 0.56714329∣0.56714329−0.5646∣×100%≈0.45%
Iteration 3 (n=3):
x4≈0.5671
Percentage relative error: 0.56714329∣0.56714329−0.5671∣×100%≈0.0076%
Example 3
Use the secant formula in four iterations to obtain an approximation of the root of the equation f(x)=x2−2x−1=0 if it lies between x0=2 and x1=3.
Iteration 1: x2=3−(32−2(3)−1)(32−2(3)−1)−(22−2(2)−1)3−2=3−22−(−1)1=3−32=37≈2.3333
Iteration 2: x3≈2.4
Iteration 3: x4≈2.4146
Iteration 4: x5≈2.4142
Mwalimu
Unasoma somo hili? Niulize nikuelezee chochote kilichomo.
Ingia ili kumuuliza Mwalimu wa AI wa Sonza kuhusu mada hii.
Ingia ili kuulizaMajadiliano
Hakuna maswali bado