Answered step by step
Verified Expert Solution
Question
1 Approved Answer
One dimensional root finding has many applications, and a common situation is called continuation, where a sequence of ( related ) roots are to be
One dimensional root finding has many applications, and a common situation is called continuation,
where a sequence of related roots are to be solved for. An elementary example of a continuation
is the numerical construction of a contour or level curve of a D function. A contour plot is a D
representation of a function of two variables, fx y that plots all curves of the form fx y c
for various constants c Figure a shows a colour plot of the HIx y function, including the
zero contour HIx y is the white dashed curve While it may seem that finding solutions
to HIx y is a D problem, there is a way to apply the D methods presented in class.
Specifically, given a point xn yn on the level curve we seek the next point
xn xn h costheta n yn yn h sintheta n
at a fixed distance h and some angle theta satisfying
fxn yn fxn h costheta n yn h sintheta n
This is a D rootfinding problem in the variable theta n The parameter h is referred to as the step
size, and is a numerical constant. It will determine the accuracy of the computed contour. The
MATLAB script CA demo.m implements the above procedure using MATLABs fzero command.
For illustration purposes it use a large stepsize value h and produces a point contour that
is unsurprisingly, a rather poor approximation to the true level curve Figure red curve
An illustration for our procedure is in Figure b where the point P on the contour thick blue
curve has just been located at the angle theta Note that there is actually a second point on the
green circle around P but it is the previous point P Hence, special care needs to be taken
that our rootfinding algorithm doesnt reverse itself. We can now repeat the procedure on the
magenta circle around P to iterate the search procedure to find P
But how can we find the first point? We can use the same angle solve procedure provided that we
begin from a point P that only needs to be within a distance h from our contour. Note in the
illustration, P is not on the contour, but the general procedure still works. For this assignment,
you can manually set P as an eyeballed point that sits near your contour.
ab
Figure : a The function HIx y and the trace determined by MATLABs fzero command. b
The rootfinding algorithm illustrated.
The goal of this assignment is to compare the secant method to the MATLABs fzero, in terms
of efficiency, and robustness use tic, toc for the former when computing the zero contour of D
functions. Begin by downloading CA demo.m a code that does the rootfinding using Matlabs
fzero command you will need to replace fzero calls inside the contour finding loop. Make sure
you download secant.m from Canvas to help you modify CA demo.m
The secant method needs an initial interval for this you will need to think about the geometry.
It turns out that the right interval for finding the angle theta n is theta n delta theta n delta where delta gives
HIxtheta n ytheta n opposite signs at the endpoints. You should start by setting delta pi but you
will be required to experiment with this parameter, as well as the h parameter. Consider all of the
following when completing your report:
Start by trying to reproduce Figure using the secant method, with h and delta pi
What happens?
Test your root finder for a variety of hdelta values to determine one where you can get all the
way around the curve. How many steps do you need to get around the curve.
What kind of convergence failures do you observe in your experiment? Offer explanations for
the failures.
How do these calculations compare against MATLABs fzero?
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