Question: clc; clear % Root lies between in the interval [ a , b ] . f = input ( ' Enter the function f (
clc; clear
Root lies between in the interval ab
f inputEnter the function fx: ;
To input a function you can use either of these two methods:
Method : @x sqrtxx
Method : inlinesqrtxx
a inputEnter left point of interval: ;
b inputEnter right point of interval: ;
epsilon inputEnter the error tolerance: ; error of tolerance
xtilde a;
absf absfxtilde; Absolute value of fx at the estimated solution.
iter ; Number of iterations
fprintf'Iteration: d Lower Interval: f Upper Interval: f Root:
f fx Abs. Value: f
iter,abxtilde,absf;
iffafb
errorEnter a valid interval. Abort the procedure.;
else
whileabsf epsilon
xtildenext a b;
iter iter ;
absf absfxtildenext;
fprintf'Iteration: d Lower Interval: f Upper Interval: f
Root: f fx Abs. Value: f
iter,abxtildenext,absf;
if fxtildenextfb
a xtildenext;
else
b xtildenext;
end
xtilde xtildenext;
end
end
fprintfThe root is f
xtilde;Problem : A Hybrid Bracketing Method pt
Review the sample code for bisection method and false position method, which can be located on Canvas
under FileSample MATLAB Code. Run a few examples on your own and see if you understand the code.
If not, speak with the instructors before proceeding with this problem.
A new method for solving a nonlinear equation is proposed in this problem. The method is a
combination of the bisection and the false position methods. The solution starts by defining an interval
that brackets the solution. Then estimated numerical solutions are determined once with the bisection
method and once with the false position method. The first iteration uses the bisection method. Write a
MATLAB userdefined function that solves a nonlinear equation with this new method. Name
the function BiFalRootFunTol where the output argument x is the solution. The input
argument Fun is a name for the function that calculates for a given it is a dummy name for the
function that is imported into BiFalRoot a and b are two initial points that bracket the root, and Tol is
the error tolerance.
Your code should include the following features:
The program should stop when the estimated relative error drops below the specified tolerance Tol.
Check if points a and are on opposite sides of the solution. If not, the program should halt and
display an error message of your choice.
The number of iterations should be limited to to avoid an infinite loop If a solution with the
required accuracy is not obtained in iterations, the program should stop and display an error
message of your choice.
Use the function BiFalRoot to solve the equation with and and observe the
answer. For Tol use
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
