Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Create and test a MATLAB function called bisection that implements the bisection root finding method. The function specifications are given in Figure 1 below Function
Create and test a MATLAB function called bisection that implements the bisection root finding method. The function specifications are given in Figure 1 below Function Name Functionalit Input Arguments (in this order) bisection Implements bisection root-finding method -Handle to function to be searched Initial bracket lower bound -Initial bracket upper bound Maximum acceptable relative approximation error Maximum acceptable number of iterations Approximation of root location -Relative approximation error of solution -Number of iterations taken -Exit flag indicating termination status) root-bisection(fun, lb, ub, err_max, iter_max) root, err) bisection(..) [root, err, numiter] bisection(...) [root, err, numlter, exitFlag] bisection 1: algorithm terminated normally (due to error being sufficiently small) 0:algorithm terminated due to max iterations being reached 1:algorithm terminated due to invalid bracket specification (no root in bracket) 2 : algorithm terminated due to invalid return value from function fun (e.g., NaN, Inf Output Arguments' (in this order) Valid Calling Syntax Exit Flag Encoding empty bracket Notes -The function should validate the input arguments to ensure there are a sufficient number, that they are of the right types, and that they are valid (iteration max should be positive, etc.). If validation fails, use the error function to terminate execution. Assume the function being passed via the function handle takes a scalar input argument and returns a scalar output Submit: (1) Your function file, bisection.m, (2) (optional) any scripts you use to test your function Create and test a MATLAB function called bisection that implements the bisection root finding method. The function specifications are given in Figure 1 below Function Name Functionalit Input Arguments (in this order) bisection Implements bisection root-finding method -Handle to function to be searched Initial bracket lower bound -Initial bracket upper bound Maximum acceptable relative approximation error Maximum acceptable number of iterations Approximation of root location -Relative approximation error of solution -Number of iterations taken -Exit flag indicating termination status) root-bisection(fun, lb, ub, err_max, iter_max) root, err) bisection(..) [root, err, numiter] bisection(...) [root, err, numlter, exitFlag] bisection 1: algorithm terminated normally (due to error being sufficiently small) 0:algorithm terminated due to max iterations being reached 1:algorithm terminated due to invalid bracket specification (no root in bracket) 2 : algorithm terminated due to invalid return value from function fun (e.g., NaN, Inf Output Arguments' (in this order) Valid Calling Syntax Exit Flag Encoding empty bracket Notes -The function should validate the input arguments to ensure there are a sufficient number, that they are of the right types, and that they are valid (iteration max should be positive, etc.). If validation fails, use the error function to terminate execution. Assume the function being passed via the function handle takes a scalar input argument and returns a scalar output Submit: (1) Your function file, bisection.m, (2) (optional) any scripts you use to test your function
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started