Question
In Matlab, To answer the following two questions you will write two programs (one for Newtons method, one for the Secant method) and then use
In Matlab,
To answer the following two questions you will write two programs (one for Newtons method, one for the Secant method) and then use these to approximate the fourth root and cube root of a number a. Do so by finding zeros of f(x) = x^4 a and f(x) = x^3 a.
The functions should be callable as [x, res , numit] = newton(fun , funp , xzero , tol , criteria , maxit)
[x, res, numit] = secant(fun, xzero, xone, tol, criteria , maxit)
Here the variables fun, funp, xzero, tol, criteria, and maxit, are the function, the functions derivative, initial guess, tolerance, convergence criteria to use (see below), and maximum number of iterations. In the secant method xzero and xone are the first two initial guesses. The returned values x, res, and numit are the approximate root, residual, and number of iterations performed.
Finally, the criteria is the convergence criteria to be used. This should be a string, either increment, or residual. In the first case, stop the iteration when the increment in iterates is less than the tolerance, and in the second, when the residual is less than the tolerance.
1. Write a computer program that uses Newtons method to approximate a root of a given function. Use
your program to approximate the 3rd root and 4th root of 2. Stop the iteration when the difference between
two successive approximations is less than 10^8. Also, try to stop the iteration when the residual is less than10^8 .
2. Write a computer program that uses the Secant method to approximate a root of a given function. Use
your program to approximate the 3rd root and 4th root of 2. Stop the iteration when the difference between
two successive approximations is less than 10^8. Also, try to stop the iteration when the residual is less than10^8 .
3. Compare the performance of Newtons method to that of the Secant method, based on the computations performed in problems 1 and 2 above.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started