This function uses the bisection algorithm to find the root of a function. It re
ID: 670178 • Letter: T
Question
This function uses the bisection algorithm to find the root of a function. It requires a valid initial bracket. Note that to lX is to not be a percentage. Use the relative approximate error but without multiplying by 100%. It is possible that your error calculation end up going infinite if the denominator is very nearly zero. This may be a reasonable step in the root finding process, so you need to come up with a way to handle this gracefully- i.e., do not declare an error and exit the function. The function should validate the input arguments to ensure there are enough of them, 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. The function should run "silently". This means that under normal operating conditions it should display nothing to the screen, should not create graphs, etc. It may display an error message (using the error function) to the command window if there is an error from which the algorithm cannot recover. The exit flag is to be an integer number. Don't pass a string '1'. You will need to add some conditional logic to your code to set this return argument appropriately.Explanation / Answer
Solution :
fval = 0 means fun(x) = 0, as desired.
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.