Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

clear all; % max_iter is not needed as a input param, (default is 100) function c = bisection(f, a, b, tol, max_iter=100) iter =

clear all;\ \ % max_iter is not needed as a input param, (default is 100)\ function c = bisection(f, a, b, tol, max_iter=100)\ iter = 0;\ \ while (iter <= max_iter) && (abs(b - a)/2 > tol)\ c = (a + b) / 2; % calculate the new root.\ if (f(a) * f(c)) > 0\ % if f(a) and f(b) have same sign\ a = c;\ else\ b = c;\ end\ iter = iter + 1;\ end\ end\ \ \ % you can derive this from the given formula, or use any standard table.\ L_5 = @(x) (-x.^5 + 25.*x.^4 - 200.*x.^3 + 600.*x.^2 - 600.*x + 120) / factorial(5);\ \ \ % plot L_5\ x = [0:0.5:5 + (5 - 1)*sqrt(5)];\ plot(x, L_5(x), '--');\ set(gca,'xtick', [0:0.5:5 + (5 - 1)*sqrt(5)]);\ grid on;\ \ % find roots\ root1 = bisection(L_5, 0, 1, 1E-4)\ root2 = bisection(L_5, 1, 1.5, 1E-4)\ root3 = bisection(L_5, 3.5, 4, 1E-4)\ root4 = bisection(L_5, 7, 7.5, 1E-4)\ root5 = bisection(L_5, 12.5, 13, 1E-4)f

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Driven Web Sites

Authors: Mike Morrison, Joline Morrison

1st Edition

061901556X, 978-0619015565

More Books

Students also viewed these Databases questions