Exercise 4.1, Problem 6:
The roots of \(f(x)\) are known or are easily found. Use 5 iterations of Newton’s method with the given initial approximation to approximate the root. Compare it to the known value of the root.
Given function: \[ f(x) = x^2 - 2 \]
Initial approximation: \[ x_0 = 1.5 \]
Answer:
Newton’s method iterative formula: \[ x_{n+1} = x_n - \frac{f(x_n)}{f'(x_n)} \]
Where: \(f'(x)\) denotes the derivative of \(f(x)\).
With R we perform five iterations of Newton’s method through a loop, starting from the initial approximation of 1.5, to approximate the positive root of \(x^2 - 2\).
f <- function(x) {
x^2 - 2
}
df <- function(x) {
2 * x
}
x0 <- 1.5
iterations <- 5
# Newton's Method Iteration
x_new <- x0
for (i in 1:iterations) {
x_next <- x_new - f(x_new) / df(x_new)
x_new <- x_next
}
x_new
## [1] 1.414214
The result, \(x_{\text{new}} = 1.414214\), is a very close approximation to \(\sqrt{2}\) which shows excellent convergence of the method toward the true root.