Question: I need the Matlab code for this assignment. Please make sure the variables match with the problem . Write a MATLAB function, called Newtons_method that

I need the Matlab code for this assignment. Please make sure the variables match with the problem.

Write a MATLAB function, called Newtons_method that inputs a function, f, its derivative f, an initial guessx0, an error tolerance, tol, and a maximum number of iterations, N, and outputs the root of f obtained using Newtons method (denoted byc), starting withx0. Your function should have an error defined by err=|xnxn1|, and stop when the error is less than the tolerance, orif the number of iterations exceeds N- whichever happens first. Your function header should look something like:

function [c,n,err] = Newtons_method(f,fp,x0,tol,N)

where n is the last iteration when you stop. Test Case: Recall that we did an example by hand, approximating the solution for f(x) =x23withan initial guess of 2 and a total of 3 iterations. Do your answers match with the by-hand answers? To test this, type the following into the command line: Newtons_method(@(x)(x.2-3),@(x)(2*x),2,10-10,3)

I need the Matlab code for this assignment. Please make sure the

3. (25 pts) Write a MATLAB function, called Newtons_method that inputs a function, f, it's derivative f', an initial guess Io, an error tolerance, tol, and a maximum number of iterations, N, and outputs the root of f obtained using Newton's method (denoted by c), starting with xo. Your function should have an error defined by err= ln In1], and stop when the error is less than the tolerance, or if the number of iterations exceeds N - whichever happens first. Your function header should look something like: 1 function [c,n, err] Newtons_method (f, fp, x0, tol,N) where n is the last iteration when you stop. Test Case: Recall that we did an example by hand, approximating the solution for f(x) = x2 3 with an initial guess of 2 and a total of 3 iterations. Do your answers match with the by-hand answers? To test this, type the following into the command line: Newtons_method (@(x) (x.^2-3),@(x) (2*x),2,10^-10,3)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!