Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a MATLAB function called Newtons_method Write a MATLAB function, called Newtons_method that inputs a function, f, its derivative f. an initial guess xo, an

Write a MATLAB function called Newtons_method

image text in transcribed

Write a MATLAB function, called Newtons_method that inputs a function, f, its derivative f. an initial guess xo, 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 = x - Xn-1), 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: function (c, n,err] = Newtons_method(f, fp, xo, N, tol) n is the last iteration when you stop. NOTE: TEST YOUR CODE ON THE EXAMPLE DONE IN CLASS. Recall that we did an example by hand, approximating the zero for the function f(x) = x2 - 3 with an initial guess of 2 and a total of N=3 iterations. Do your answers match with the by-hand answers? To test this case, type in 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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Students also viewed these Databases questions