1. Engineering
  2. Computer Science
  3. please use matlab and post code i also provided the...

Question: please use matlab and post code i also provided the...

Question details

Please use matlab and post code. i also provided the templates for each method

2. Consider the function f(x)-x cos(x) [2 points] Using MATLASB, plot the function over the interval -0.5 Sx S 1.4 [1 point] Verify that the function has a zero near x -0.74. What is the value of f at this x value?] a. b. Obtain approximations to the zero near x 0.74 using c. [5 points] The Bisection method, with starting interval [0.25,1]: d. [4 points] The Method of False Position with starting interval [0.25,1]: Note that you must devise convergence criteria for the methods that you use above. You may choose to define convergence as being when then value of f is close to zero, or if change in estimate of the root location (x) from step to step is close to zero. The criteria should be the same for both methods. 12 points) Report the number of steps that each method required to find the root location e. f [3 points] use tic and toe to time each routine, and report the execution time for each iterative procedure

Program 22 (Bisection Method). To approximate a root of the equation f(x) 0 in the interva) la, b). Proceed with the method only if f(x) is continuous and f(a) and ftb) have opposite signs. function c,erryc]-biaect(f,a,b,delta) %input -t is the function input as a string ,f, - a and b are the left and right end points - delta is the tolernce %Output-c is the zero -etr is the error estimate for c ya feval(?,a); yb feval(f,b) if yaryb>0, break, end maxi-1tround log(b-a)-log delta))/log(2)): for k 1:naxi c (a+b)/2 yc tevalff.c): if yc #0 a«c ; b c; yb-y: olse a-ci ya yc: end if b-a < delta, break, end end c (a+b)/2: err abs (b-a); yc feval (f ,c),

60 CHAP. 2 THE SOLUTION OF NONLINEAR EQATIONS f(x)0 Program 2.3 (False Position or Regula Falsi Method). To approximate a root of the equation f(x)-0 in the interval la.b). Proceed with the method only if f(x) is continuous and f(a) and f (h) have opposite signs. function [c,err,yc]-regula(f,a,b,dolta,epailon,maxi) %Input - f 16 the function input as a string ,f, - a and b are the left and right end points - delta is the tolerance for the zero - epsilon is the tolerance for the value of f at the zero - maxi is the maximum nuaber of iterations %Output- c is the zero - ycf(c) - err is the error estinate for c ya-feval (f.a) yb-feval(t.b): if ya yb>o f(a)sf (b) >0), disp(Note: break, end for k-1:max1 dxeyb (b-a)/(yb-ya); c-b-dx; усfeval (f ,c) ; if yc--o, break; elseif ybeyc>o b c yb-yc ; lse ya-yc dx-min(abs (dx),ac); if abs(dx) <delta, break, end if abe(yc) Kepsilon, break, end end Ci err-abe(b-a)/2; yc-feval(f.e); 12.

Solution by an expert tutor
Blurred Solution
This question has been solved
Subscribe to see this solution