Question: Write down the bisection algorithm to find a zero of a function f(x) with x [a,b]. Implement the algorithm in MATLAB and use the algorithm
Write down the bisection algorithm to find a zero of a function f(x) with x [a,b]. Implement the algorithm in MATLAB and use the algorithm to compute the sequence {xk}k0 of a zero of the functions given below. Create a function with input values (a, b, tol and nmax) where tol is the accepted tolerance and nmax is the maximum allowed number of iterations (in order to avoid infinite loops). For the output values choose the ones you consider necessary. In each case, 1 Find the interval [a, b] which contains a unique positive zero of each function. Compute the errors |ek| = |xk x|. Computethebounds|xc | 1 (b a ),wherec = 1(a +b ). n 2n+1 0 0 n 2 n n Print the sequence {xk} for k = 0,1,2,... (a) f(x) = x4 0.25 (b) f(x) = 3x3 x2 18x+6. Hint: in case you want to have an idea of which are the roots of a poly- nomial p(x) = anxn +...+a1x+a0 , MATLAB can find them using the command: p = [a_n ... a_1 a_0]; roots(p)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
