Question: Create a Matlab function that, Takes as input: a function f, its derivative fderv, the endpoints of an interval a and b. Checks if a

Create a Matlab function that,

Takes as input: a function "f, its derivative "fderv, the endpoints of an interval a and b.

Checks if a b changes the value of a with the value of b and vice-versa. If a = b the function should error out using the "error(" an explanation for failure) command of matlab.

Generates an array x slicing the interval [a,b] with a sampling length of 0.001

. Evaluates the function on the above array and gets a new array y.

The evaluation array y is searched for any value between [-0.0001, 0.0001) and the relevant x points are recorded into a new array named "xguess. You can do this by using a for loop, and getting the length of the array y with "length(y). Hint: create a new empty array with "xguess=[]" before the loop and place every new item you find to the tail of the array with the syntax "xguess=[xgues, whatever new item)

The attached myNewton Tol function is called for the inputs of this function and a tolerance of 0.0001, and the result recorded as "xNewton. The number xNewtol is compared with every entry of "xguess (again perhaps with a loop). If any entry of xguess is at a distance of 0.000001 or less function outputs 1, if not function outputs 0.

Comment everything like we did in the lecture, and try to explain what you think this function is for. Attach File Browse My Computer Browse Content Collection

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!