Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Flowchart of those code please. 4 Il 7 9 Main.mx bisection.mx + 1 % defining function f(x) 2 - f = @(x) x.^3 - 7*x.^2

image text in transcribedimage text in transcribed

Flowchart of those code please.

4 Il 7 9 Main.mx bisection.mx + 1 % defining function f(x) 2 - f = @(x) x.^3 - 7*x.^2 + 4; 3 % Will use interval x = 5 to 10 % calling function bisection to find root 5 a = 5; 6 b = 10; tolerance = 0.01; 8 maxiter = 100; % fetching root on params LO root = bisection(f, a,b, tolerance, maxiter); 11 % Ploting function f(x) 12 x = 5:0.01:10; 13 plot(x, f(x)); 14 hold on; 15 % plot output line to identify closet root 16 yline(0, '--'); 17 18 % plot output line to identify F(X) 19 - xline (root,"--"); 20 21 % labeling plot 22 xlabel("x"); 23 ylabel("y"); 24 title("f(x)"); 25 % legend 26 legend ("f(x)","Closest Root","root"); 1 7 Main.m bisection.mx + % bisection function with input function, a and b, tolerance and maxiter 2 function [root] = bisection(f, a, b, tolerance, maxiter) 3 % checking if initial and end point lies at same size of axis 4 if f(a)*f(b) > 5 disp('Wrong choice for a and b'); 6 else % otherwise 8 % defining root as mid value of a and b 9 root = (a + b)/2; 10 % defining error and initializing it with high value 11 - err = 1; 12 % defining counter to loop 13 i = 1; 14 - - while err > tolerance && i 5 disp('Wrong choice for a and b'); 6 else % otherwise 8 % defining root as mid value of a and b 9 root = (a + b)/2; 10 % defining error and initializing it with high value 11 - err = 1; 12 % defining counter to loop 13 i = 1; 14 - - while err > tolerance && i

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_2

Step: 3

blur-text-image_3

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 And Transaction Processing

Authors: Philip M. Lewis, Arthur Bernstein, Michael Kifer

1st Edition

0201708728, 978-0201708721

More Books

Students also viewed these Databases questions