Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In MATLAB: Suppose a user wants to make a root finder in Matlab. Create a script that does the following: Allows the user to enter

In MATLAB: Suppose a user wants to make a root finder in Matlab. Create a script that does the following:

  1. Allows the user to enter a function, f(x), the end-points of the plot window and the method to find the root.
  2. Plot the function for the user to view the location of roots.
  3. Using a case-switch, call 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.

*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

Expert Performance Indexing In SQL Server

Authors: Jason Strate, Grant Fritchey

2nd Edition

1484211189, 9781484211182

More Books

Students also viewed these Databases questions

Question

=+5. Why might validity be a concern during an interview process?

Answered: 1 week ago

Question

What is DDL?

Answered: 1 week ago