Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Below is the correct code for the false - position method. Using the image provided modify this code to create a script for the modified

Below is the correct code for the false-position method. Using the image provided modify this code to create a script for the modified false-position method. (Focus on highlighted parts)The limitation of the False-position method is its one-sidedness. If the root is close to
either upper or lower bound, one of the bracketing points is keep fixed. To overcome this
issue, the modified false-position method was developed. The pseudo code for the
modified false-position method is shown down below.
=> Fill the right column in the table below with your script
clc; clear all; close all;
% Parameters
xl =12; % lower bound
xu =16; % upper bound
es =5e-10; % tolerance
imax =1000; % max iteration
% Initialization of the plot
figure;
xlabel('Iteration');
ylabel('Approximate Relative Error (%)');
title('Error vs Iterations');
hold on;
xlim([035]);
set(gca, 'YScale', 'log');
grid on;
% Find root
[xx2, iter2]= FalsePosition(xl, xu, es, imax)
function [xx, iter]= FalsePosition(xl, xu, es, imax)
% Initialization
iter =0;
xr = xl;
ea =100;
% Graph shows 35 iterations for iter 1:35
for iter =1:35
% Step 2: update root
xrold = xr;
xr = xu -(f(xu)*(xl - xu))/(f(xl)- f(xu));
% Step 3: error
if xr ~=0 && iter >1
ea = abs((xr - xrold)/ xr)*100;
end
% Plot relative error
semilogy(iter, ea,'ro');
% Step 4: Update Boundary
test = f(xl)* f(xr);
if test 0
xu = xr;
elseif test >0
xl = xr;
else
ea =0;
end
% Break if tolerance is reached
if ea es
break;
end
end
xx = xr;
end
%% Function Evaluation
function [fc]= f(x)
g =9.81;
m =68.1;
t =10;
fc = g * m / x *(1- exp(-x / m * t))-40;
end
image text in transcribed

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

PostgreSQL Up And Running A Practical Guide To The Advanced Open Source Database

Authors: Regina Obe, Leo Hsu

3rd Edition

1491963417, 978-1491963418

Students also viewed these Databases questions

Question

Describe Table Structures in RDMSs.

Answered: 1 week ago