Question: 2. (50 points) Prepare a Matlab function that: Takes a function f and two values a, b and tol as inputs. Makes sure that a

2. (50 points) Prepare a Matlab function that: Takes a function f and two values a, b and tol as inputs. Makes sure that a #b, else errors out. Generates an array x between a and b with a step length of 0.1 . Generates an array y, the evaluation of f at x. Searches for all negative entries in y, and records the relevant entries of x into a new array xNegEval. Searches for all positive entries in y, and records the relevant entries of x into a new array xPosEval. If either xNeqEval or xPosEval is empty (i.e of length 0!) then items 3-7 in this list is repeated for step length 0.01, 0.001, 0.0001, ... so on and so forth. If both xNeqEval and xPosEval are non-empty, the false-position method is applied until we reach the desired tolerance. The estimate is outputted as "rootEst" Comment everything!, Also specify in your comments what you nk this function has accom- plished. Upload your solution as Question2.m Wrong file formats get -20 pts! NO SCREEN CAPS
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
