MAKE A FLOWCHART PLEASE  clc; clear; function [] = Bisection(xl,xu,es,imax) ea = 100 xr = (xu+xl)/2; x=xr fr=evstr(f) while (ea>es) a=fl-fu; if (a==0) then mprintf("Error: Division by Zero") abort end test = fl * fr; mprintf(" %d %10f %10f %10f %12.7f %12f %12.f %10.7f\n",iter,xl,xu,xr,fl,fu,fr,ea); if (test<0) then xu=xr; elseif (test>0) then xl=xr; elseif (test==0) then mprintf("\n\nThe root of the equation is %f",xr) abort end x=xl fl=evstr(f) x=xu fu=evstr(f) xrold=xr xr=(xu+xl)/2; x=xr fr=evstr(f) ea=abs((xr-xrold)/xr)*100; iter=iter+1; test=fl*fr if ea < es then mprintf(" %d %10f %10f %10f %12.7f %12.f %12.f %10.7f\n",iter,xl,xu,xr,fl,fu,fr,ea); mprintf("\n\nThe approximate root for the given function is %f",xr) abort end if iter > imax mprintf("The approximate root for the given function is %f",xrold) mprintf("\nSlowly converges. It is suggested that the initial values should be change"); abort end end endfunction //main disp("This program will solve/give the approximate root of any given nonlinear algebraic equations using the Bisection Method") f=input("Input the function to be evaluated: ",'string') xl=input("Enter the lower limit: ") x=xl fl=evstr(f) if (fl==0) then mprintf("Lower limit is the root. ") end xu=input("Enter an upper limit: ") x=xu fu=evstr(f) if (fu==0)then mprintf("Upper limit is the root. ") abort end b = fl*fu; if (b>0) then mprintf("The initial guesses are invalid. f(xl)*f(xu) should be less than zero"); abort end es=input("Input the value of accepted tolerance of error (es): ") imax=input("Enter the desired number of iterations: "); iter=1 mprintf(" iter \t\txl \t \t xu \t xr \t f(xl) \t f(xu) \t\t\tf(xr) ea\n");//for output table Bisection(xl, xu, es, imax)

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter9: Completing The Basics
Section9.3: The String Class
Problem 7E
icon
Related questions
Question

MAKE A FLOWCHART PLEASE 

clc;
clear;

function [] = Bisection(xl,xu,es,imax)
ea = 100
xr = (xu+xl)/2;
x=xr
fr=evstr(f)
while (ea>es)
a=fl-fu;
if (a==0) then
mprintf("Error: Division by Zero")
abort
end
test = fl * fr;
mprintf(" %d %10f %10f %10f %12.7f %12f %12.f %10.7f\n",iter,xl,xu,xr,fl,fu,fr,ea);
if (test<0) then
xu=xr;
elseif (test>0) then
xl=xr;
elseif (test==0) then
mprintf("\n\nThe root of the equation is %f",xr)
abort
end
x=xl
fl=evstr(f)
x=xu
fu=evstr(f)
xrold=xr
xr=(xu+xl)/2;
x=xr
fr=evstr(f)
ea=abs((xr-xrold)/xr)*100;
iter=iter+1;
test=fl*fr
if ea < es then
mprintf(" %d %10f %10f %10f %12.7f %12.f %12.f %10.7f\n",iter,xl,xu,xr,fl,fu,fr,ea);
mprintf("\n\nThe approximate root for the given function is %f",xr)
abort
end
if iter > imax
mprintf("The approximate root for the given function is %f",xrold)
mprintf("\nSlowly converges. It is suggested that the initial values should be change");
abort
end
end
endfunction

//main

disp("This program will solve/give the approximate root of any given nonlinear algebraic equations using the Bisection Method")
f=input("Input the function to be evaluated: ",'string')
xl=input("Enter the lower limit: ")
x=xl
fl=evstr(f)
if (fl==0) then
mprintf("Lower limit is the root. ")
end
xu=input("Enter an upper limit: ")
x=xu
fu=evstr(f)
if (fu==0)then
mprintf("Upper limit is the root. ")
abort
end
b = fl*fu;
if (b>0) then
mprintf("The initial guesses are invalid. f(xl)*f(xu) should be less than zero");
abort
end
es=input("Input the value of accepted tolerance of error (es): ")
imax=input("Enter the desired number of iterations: ");
iter=1
mprintf(" iter \t\txl \t \t xu \t xr \t f(xl) \t f(xu) \t\t\tf(xr) ea\n");//for output table

Bisection(xl, xu, es, imax)



Expert Solution
steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning