Question: 3 . 1 6 Write a MATLAB user - defined function that solves for a root of a nonlinear equation f ( x ) =

3.16 Write a MATLAB user-defined function that solves for a root of a nonlinear equation f(x)=0 using
the bisection method. Name the function Xs = BisectionRoot(Fun,a,b). The output argument Xs is
the solution. The input argument Fun is a name for the function that calculates f(x) for a given x(it is a
dummy name for the function that is imported into BisectionRoot); a and b are two points that
bracket the root. The iterations should stop when the tolerance in f(x)(Eq.(3.5)) is smaller than 0.000001.
The program should check if points a and b are on opposite sides of the solution. If not, the program
should stop and display an error message. Use BisectionRoot to solve Problem 3.2.
problem 3.2: Determine the root of f(x)= x-2e^(-x) by:
a) using the bisection method. start a =0 and b =1, and carry out the first three iterations.
b)using the secant method. Start with the two points, x1=0 and x2=1, and carry out the first three iterations.
c)using the Newton's method. Start x1=1 and carry out the first three iterations.
 3.16 Write a MATLAB user-defined function that solves for a root

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!