## Transcribed Text

Question (from Gilat and Subramanian) In the Regula Falsi search technique it often happens
that one of the two walls remains stationary It has been proposed that, whenthishappens the
function value at the stationary wall should be divided by factor when applying the formula
for
calculating NROOR and that this factor should increase over time. The idea is that this can make
the search more efficient.
Once wall has been stationary for three successive iterations the function value at that wall
should be divided by factor of when applying the formula, if the wall remains stationary for
another three iterations this factor should be doubled to and so on, with the factor being
doubled every three iterations Everything resets when wall that was stationary is moved.
No
factor is applied until wall has once again been stationary for three successive iterations at
which point factor of is used, and so on.
All of the above can neatly be summarized by taking the formula for calculating NROOT to be
NROOT Thon
D1 f(xman)
where Dit is the factor for the low wall and D1 is the factor for the high wall
Initially both DL are and the formula is entirely equivalent to the normal Regula Falsi
formula. As long as the high wall is stationary Dil is doubled every three iterations and as
long
as the low wall is stationary D1 is doubled every three iterations Any movement of the high
wall resets Dirto and any movement of the low wall resets Dito 1.
Produce function m- file (to be called modRegFal. m) that implements the algorithm described
above. You are not expected to start from scratch. Instead you should take the regFal.r in the
sample material and make appropriate modifications to it.
Test your function by using it, regFal m, and bisect.m to solve the following root finding
problems:
i) root of e* x3 between 1 and 3, desired error 1x10
ii) root of 2 X2 between and 6, desired error 1x106
iii)
root of 1/(1 + 60e-0.15x) 0.6 between 10 and 50, desired error 1x10"6
What were the results of your testing? Does the modified approach appear to be better in any
way? Add comment that answers these questions at the end of you function (there will be a
mark or two for saying something reasonable).
Question Write function m-file (to be called myAsin) that uses the principle of Newton
Raphson search to compute the inverse sin of value. If the input value is not between and
(inclusive of these values) your function should generate an error Otherwise it should return
value between -s/2 and n/2 (like the built- in function asin, your function should work in radians).
Your first step is to express the problem in root finding form.
Test your function by creating single graph that shows the values of both my Asin(x) and asin(x)
(the built-in function) for from to 1. Plot the my. Asin values first using solid black line.
Ther plot the asin values usinga dotted red line. If your function works correctly the result
should be single d/black line
Question (from Chapra, modified) Two corridors, one of width wl and one of width w2. meet
at an angle of a degrees (see diagram below). We are interesting in determining the length of the
longest ladder that can be taken from one corridor to the other
wl
w2
As the ladder is swung from one corridor to the other, angle, changes from zero to 180
a
degrees. For any given B the maximum possible ladder length can be calculated using
wl
w2
L(B)
sin() sin(180-a- B)
The actual ladder must fit for every possible value of B and the length of the longest ladder that
can be taken around the corner can therefore be found by finding the minimum of L(B).
Produce function (ladderLength) that, given wl. w2. and a (in degrees), computes and returns
the length of the longest ladder that can be taken around the corner.
Write: no input /no output function (Q3 m) that has adderLength as subfunction and that
does the following
i) Assume wl m and w2 .5m. Produce plot giving the longest possible ladder length for
a from 90 to 135 degrees.
ii) Assume wl w2anda- 120 degrees. What is the the minimum corridor width that will
allow 5 m ladder to be taken around the corner?
iii) Assume w2 3. (0.9 * w1) and 95 degrees. What value of wl maximizes the allowable
ladder length? At this value of wl, what is the longest ladder that can be taken around the
corner?
All required quantities should be output as part of nicely formatted messages (use fprintf)
Question 4 Two ways of finding minimum are covered in the notes. One is "crude"
approach in whichthe two test points are located at 49 and 0.51 of the interval, and the other is
the "Golden Section" algorithm.
If we are allowed certain number of function evaluations, each approach will reduce EMAX to
some fraction of the original interval width Ax Let (the error ratio) be EMAX for the Golden
Section approach divided by Emax for the crude approach. Note that R does not dependupon
the original interval width Ax as the width appears in both error expressions and so cancels out
Write script (04. m) that plots R against the number of function evaluations for from to 24
function evaluations in steps of function evaluations.. Use xx" markers for to show the data
points.
Assume that. when a search terminates the midpoint of the reduced interval is always taken as
the final answer.

These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction
of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice.
Unethical use is strictly forbidden.

function [x,Emaxs] = crude (f, xL, xU, Edes, display)

% CUDE Finds a minimum by performing a bisection like search

% Inputs: f = a function of one variable

% xL = lower bound of region containing minimum

% xU = upper bound of region containing minimum

% Edes = function stops when x is guaranteed within Edes of minimum

% display = display option (0 = no display (default), 1 = display)

% Outputs: x - estimate of minimum

% Emaxs - value of Emax as a function of iteration number k;

if nargin < 5; display = 0; end

if display

fprintf ...

(' N xL xA xB xU Emax\n');

end

functionCount = 0;

for k = 0 : 1000

Emax = (xU - xL) / 2;

Emaxs(k+1)=Emax;

xA = xL + 0.49 * (xU - xL); fxA = f(xA);

xB = xL + 0.51 * (xU - xL); fxB = f(xB);

functionCount = functionCount + 2;

if display

fprintf ('%5d %12.6f %12.6f %12.6f %12.6f %12.6f\n', ...

k, xL, xA, xB, xU, Emax);

end

if Emax <= Edes

x = (xL + xU) / 2; % take midpoint as final answer

if display

% the last two function evaluations weren't actually needed

% (the results weren't used) and could be eliminated

fprintf ('Tolerance achieved after %d function evaluations.\n', ...

functionCount - 2);

end...