Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Suppose an individual wants to create a root finder function. Using MATLAB, create a script for the user that does the following: 1. Allows an

Suppose an individual wants to create a root finder function. Using MATLAB, create a script for the user that does the following:
1. Allows an individual to enter a function, f(x), the end-points of the plot window, and the method to find the root. *(The methods needed are below)
2. Plots the function for the user to view the location of roots.
3. Uses a case-switch, call each function bisection.m, fixed.m, newton.m or secant.m (each of these should prompt the user for the necessary input information). *Note: these are functions you will write!
4. Plot the points generated through each pass in the algorithmic loop.
5. Return the root, the time elapsed, and the number of iterations.
Run your script with the following function using each method: f(x) = x^2 sin(x)
*Note: find the root to within 1.e 16 accuracy.
*For part 3
Bisection Method
% Bisection Method
% a is a point left of the root
% b is a point right of the root
% m is the point halfway between a and b
m = a + (b-a)/2;
if sign(f(a)) == sign(f(m))
a = m;
else
b = m;
end
Fixed-point Method
% Fixed-point f(x) = g(x) - x = 0
% which implies: x(n+1) = g(x(n))
p = g(p0);
Newton Method
% Newtons Method
% x is the guess
% xn is the new guess
% f1 is the first derivative
xn=x-f(x)/f1(x);
Secant Method
% Secant Method
% x0 and x1 are guesses that are distinct
% xn is the new guess that will connect to x1
xn = x1 - f(x1)*(x1-x0)/(f(x1)-f(x0));
Please show all work. Thanks!

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

AutoCAD Database Connectivity

Authors: Scott McFarlane

1st Edition

0766816400, 978-0766816404

More Books

Students also viewed these Databases questions

Question

Decide on best content

Answered: 1 week ago

Question

4. What action should Cherita Howard take and why?

Answered: 1 week ago