Question: this is que flasepos function [root,fx,ea,iter]=falsepos(func,xl,xu,es,maxit,varargin) % falsepos: root location zeroes % [root,fx,ea,iter]=falsepos(func,xl,xu,es,maxit,p1,p2,...): % uses false position method to find the root of func %

this is que
flasepos
function [root,fx,ea,iter]=falsepos(func,xl,xu,es,maxit,varargin)
% falsepos: root location zeroes
% [root,fx,ea,iter]=falsepos(func,xl,xu,es,maxit,p1,p2,...):
% uses false position method to find the root of func
% input:
% func = name of function
% xl, xu = lower and upper guesses
% es = desired relative error (default = 0.0001%)
% maxit = maximum allowable iterations (default = 50)
% p1,p2,... = additional parameters used by func
% output:
% root = real root
% fx = function value at root
% ea = approximate relative error (%)
% iter = number of iterations
if nargin
test = func(xl,varargin{:})*func(xu,varargin{:});
if test>0,error('no sign change'),end
if nargin
if nargin
iter = 0; xr = xl; ea = 100;
while (1)
xrold = xr;
fxl = func(xl,varargin{:});
fxu = func(xu,varargin{:});
xr = xu -fxu * (xl - xu)/(fxl-fxu);
iter = iter + 1;
if xr ~= 0,ea = abs((xr - xrold)/xr) * 100;end
test = func(xl,varargin{:})*func(xr,varargin{:});
if test
xu = xr;
elseif test > 0
xl = xr;
else
ea = 0;
end
if ea = maxit,break,end
end
root = xr; fx = func(xr, varargin{:});
bisect
function [root,fx,ea,iter]=bisect(func,xl,xu,es,maxit,varargin)
% bisect: root location zeroes
% [root,fx,ea,iter]=bisect(func,xl,xu,es,maxit,p1,p2,...):
% uses bisection method to find the root of func
% input:
% func = name of function
% xl, xu = lower and upper guesses
% es = desired relative error (default = 0.0001%)
% maxit = maximum allowable iterations (default = 50)
% p1,p2,... = additional parameters used by func
% output:
% root = real root
% fx = function value at root
% ea = approximate relative error (%)
% iter = number of iterations
if nargin
test = func(xl,varargin{:})*func(xu,varargin{:});
if test>0,error('no sign change'),end
if nargin
if nargin
iter = 0; xr = xl; ea = 100;
while (1)
xrold = xr;
xr = (xl + xu)/2;
iter = iter + 1;
if xr ~= 0,ea = abs((xr - xrold)/xr) * 100;end
test = func(xl,varargin{:})*func(xr,varargin{:});
if test
xu = xr;
elseif test > 0
xl = xr;
else
ea = 0;
end
if ea = maxit,break,end
end
root = xr; fx = func(xr, varargin{:});
 this is que flasepos function [root,fx,ea,iter]=falsepos(func,xl,xu,es,maxit,varargin) % falsepos: root location zeroes
this is ans please write this code in matlab and make secreen shoot and show the output
% [root,fx,ea,iter]=falsepos(func,xl,xu,es,maxit,p1,p2,...): % uses false position method to find the root of
func % input: % func = name of function % xl, xu
= lower and upper guesses % es = desired relative error (default
= 0.0001%) % maxit = maximum allowable iterations (default = 50) %
p1,p2,... = additional parameters used by func % output: % root =
real root % fx = function value at root % ea =
approximate relative error (%) % iter = number of iterations if nargin
Question1: Determine the real root for the following equation f(x)=1122x+17x21.25x3 a) Graphically using any tool (Handwriting is not acceptable). b) Using Bisection method to determine the root between 1 and 2 , and calculate the relative approximate error for each iteration. Iterate until a Step 1/2 Done while (current_iteration && abs (out) > epsilon) out=f(x0) if out epsilon) out=f(x0); if out epsilon) out=f(0) if out

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!