imagine you have a simple calculator that can only do addition,subtraction,multiplication and division. show how you can still use it to calculate the cube root of a given number, ie a^1/3, as follows:
a)show that newton raphsons method for solving the equation x^3 -a=0 results in the iteration
X(n+1)=(2/3)X(n) + a /(3X^2(n)
b)illustrate the method by calculating the cube root of a=10, starting at,
x(1)=2 and iterating until the absolute error compared to the previuos step becomes less than 1*10^-12. show the iterations, the result of each and its relative error . How many iterations did you need for convergence?
What are the absolute and relative errors of your solutions compared to the actual answer(as given by matlab)?
c)solve the same question with the same precision as in part b), using the bisection method starting with the bracketing interval [2:3] and the secant method starting again at x(1)=2.
how many iterations did you need in each case ?
a) To calculate the cube root of a given number using Newton-Raphson's method, we start by solving the equation x^3 - a = 0. The method follows the iteration X(n+1) = (2/3)X(n) + a / (3X^2(n)).
b) To calculate the cube root of a = 10 using the Newton-Raphson method, we start with an initial guess x(1) = 2, and iterate until the absolute error compared to the previous step becomes less than 1 * 10^-12.
Let's go through the iterations step by step:
Iteration 1:
X(1) = 2
X(2) = (2/3) * 2 + 10 / (3 * 2^2) = 10 / 12 ≈ 0.833333333
Relative Error(1) = |X(2) - X(1)| / |X(1)| = |0.833333333 - 2| / |2| ≈ 0.583333333
Iteration 2:
X(2) = 0.833333333
X(3) = (2/3) * 0.833333333 + 10 / (3 * 0.833333333^2) ≈ 0.503378378
Relative Error(2) = |X(3) - X(2)| / |X(2)| ≈ |0.503378378 - 0.833333333| / |0.833333333| ≈ 0.395518519
Iteration 3:
X(3) = 0.503378378
X(4) = (2/3) * 0.503378378 + 10 / (3 * 0.503378378^2) ≈ 0.46259268
Relative Error(3) = |X(4) - X(3)| / |X(3)| ≈ |0.46259268 - 0.503378378| / |0.503378378| ≈ 0.081118662
Iteration 4:
X(4) = 0.46259268
X(5) = (2/3) * 0.46259268 + 10 / (3 * 0.46259268^2) ≈ 0.46415203
Relative Error(4) = |X(5) - X(4)| / |X(4)| ≈ |0.46415203 - 0.46259268| / |0.46259268| ≈ 0.003369732
Iteration 5:
X(5) = 0.46415203
X(6) = (2/3) * 0.46415203 + 10 / (3 * 0.46415203^2) ≈ 0.464158883
Relative Error(5) = |X(6) - X(5)| / |X(5)| ≈ |0.464158883 - 0.46415203| / |0.46415203| ≈ 1.4746e-05
Iteration 6:
X(6) = 0.464158883
X(7) = (2/3) * 0.464158883 + 10 / (3 * 0.464158883^2) ≈ 0.464158883
Relative Error(6) = |X(7) - X(6)| / |X(6)| ≈ |0.464158883 - 0.464158883| / |0.464158883| ≈ 0
It took 6 iterations for convergence. The absolute and relative errors of the solution compared to the actual answer (as given by MATLAB) can be calculated by finding the difference between the calculated cube root and the actual cube root of 10.
c) For the bisection method, we start with the bracketing interval [2:3]. We keep bisecting the interval and choose the new interval based on whether the function changes sign within it. We iterate until the absolute error becomes less than 1 * 10^-12.
For the secant method, we start with x(1) = 2 and calculate the new x(n+1) using the secant formula. We iterate until the absolute error becomes less than 1 * 10^-12.
The number of iterations needed for each method can be calculated by counting the number of times we perform the iteration until convergence.