Question: In MATLAB please 3 Another Experiment With Function Handles Write a function xbwbisection (f, a, b, tol) and a function xn=newton (f,x0,tol) which both find

In MATLAB please
In MATLAB please 3 Another Experiment With Function Handles Write a function

3 Another Experiment With Function Handles Write a function xbwbisection (f, a, b, tol) and a function xn=newton (f,x0,tol) which both find a zero of f(x) in the interval [a, b], using the bisection and newton algo rithms, respectively, discussed in class. For the newton function, use the function deriv from problem (2) of this assignment to compute the derivative of the function at each iteration You can find the pseudo-code for both methods below. Then, find the zero of the following functions near the given points: f(x) = cos() + sin(2x) near 1 = 2 g(x) = 1 - 5 In(x) near r=1 Also, display the number of iterations each method takes to find the zero. In writing the driver routine that calls bisection and neuton, you are free to define the functions f(a) and g(a) as anonymous functions or subfunctions (in which case the driver routine will itself be a function). Pseudo-code for bisection method: a = left end point b = right end point N1 # Stop only when max iteration is reached or solution is found c = (a + b)/2 # new midpoint While N TOL N = N + 1 # increment step counter c = (a + b)/2 # new midpoint # Determine new interval If sign (f(c)) == sign (f (a)) then a = c else b = c End If Endwhile Pseudo-code for Newton's method: abs(f(x)) X = some guess N = 0 While I TOL N = N + 1 # Do the Newton iteration x = x - f(x) / f'(x) EndWhile 3 Another Experiment With Function Handles Write a function xbwbisection (f, a, b, tol) and a function xn=newton (f,x0,tol) which both find a zero of f(x) in the interval [a, b], using the bisection and newton algo rithms, respectively, discussed in class. For the newton function, use the function deriv from problem (2) of this assignment to compute the derivative of the function at each iteration You can find the pseudo-code for both methods below. Then, find the zero of the following functions near the given points: f(x) = cos() + sin(2x) near 1 = 2 g(x) = 1 - 5 In(x) near r=1 Also, display the number of iterations each method takes to find the zero. In writing the driver routine that calls bisection and neuton, you are free to define the functions f(a) and g(a) as anonymous functions or subfunctions (in which case the driver routine will itself be a function). Pseudo-code for bisection method: a = left end point b = right end point N1 # Stop only when max iteration is reached or solution is found c = (a + b)/2 # new midpoint While N TOL N = N + 1 # increment step counter c = (a + b)/2 # new midpoint # Determine new interval If sign (f(c)) == sign (f (a)) then a = c else b = c End If Endwhile Pseudo-code for Newton's method: abs(f(x)) X = some guess N = 0 While I TOL N = N + 1 # Do the Newton iteration x = x - f(x) / f'(x) EndWhile

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!