The Root Finding Algorithms - Homework 3 | ME 2016, Assignments of Computer Science

Material Type: Assignment; Class: Computing Techniques; Subject: Mechanical Engineering; University: Georgia Institute of Technology-Main Campus; Term: Fall 2016;

Typology: Assignments

Pre 2010

Uploaded on 08/04/2009

koofers-user-31j-1
koofers-user-31j-1 🇺🇸

10 documents

1 / 7

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Page 1
ME 2016 Sections
Fall Semester 2007
Computing Techniques 3-0-3
Homework Assignment 3
Root Finding Algorithms
Solution
Task 1: Solve a Root Finding problem with pencil and paper
2sin( ) 5
x
ex=+
1) convert into standard root-finding formulation: 2
() sin() 5 0
x
fx e x
=
−−=
2) compute the derivatives (needed for Newton Raphson):
2
2
() 2 cos()
() 4 sin()
x
x
f
xe x
f
xe x
=−
′′ =+
Bisection
i xl xu f(xl) f(xu) xr f(xr) |Ea| Delta_x/2^n
0 0 1 -4 1.547585 0.5 -2.76114
1 0.5 1 -2.76114 1.547585 0.75 -1.19995 0.25 0.5
2 0.75 1 -1.19995 1.547585 0.875 -0.01294 0.125 0.25
3 0.875 1 -0.01294 1.547585 0.9375 0.714738 0.0625 0.125
Newton Raphson
i x(i) f(x(i)) (df/dx)(x(i)) x(i+1) Ea proportionality constant
0 1 1.547585 14.23781 0.891305
1 0.891305 0.167456 11.2623 0.876436 -0.01487
2 0.876436 0.002689 10.90241 0.876189 -0.00025 -1.11545
3 0.876189 7.25E-07 10.89653 0.876189 -6.7E-08 -1.09435
first derivative at the root is: 10.89653
second derivative at the root is: 23.84153
proportionality constant = -1.094<-- theoretical prediction
Task 2: Error Analysis
For Bisection: 0
2
n
an
x
EΔ
=
For Newton Raphson: 2
,1 ,
()
2()
r
ti ti
r
fx
E
E
fx
+
=
Interpretation Questions:
1) For each algorithm, describe in words how the absolute approximate error changes
from one iteration to the next.
For bisection, the size of the absolute approximate error is divided by 2 in every iteration.
For Newton Raphson, the number of significant digits (almost) doubles in every iteration.
pf3
pf4
pf5

Partial preview of the text

Download The Root Finding Algorithms - Homework 3 | ME 2016 and more Assignments Computer Science in PDF only on Docsity!

ME 2016 Sections

Fall Semester 2007

Computing Techniques 3-0-

Homework Assignment 3

Root Finding Algorithms

Solution

Task 1: Solve a Root Finding problem with pencil and paper

e^2^ x = sin( ) x + 5

  1. convert into standard root-finding formulation: f ( ) x = e^2 x − sin( ) x − 5 = 0

  2. compute the derivatives (needed for Newton Raphson):

2 2

( ) 2 cos( ) ( ) 4 sin( )

x x

f x e x f x e x

Bisection i xl xu f(xl) f(xu) xr f(xr) |Ea| Delta_x/2^n 0 0 1 -4 1.547585 0.5 -2. 1 0.5 1 -2.76114 1.547585 0.75 -1.19995 0.25 0. 2 0.75 1 -1.19995 1.547585 0.875 -0.01294 0.125 0. 3 0.875 1 -0.01294 1.547585 0.9375 0.714738 0.0625 0.

Newton Raphson i x(i) f(x(i)) (df/dx)(x(i)) x(i+1) Ea proportionality constant 0 1 1.547585 14.23781 0. 1 0.891305 0.167456 11.2623 0.876436 -0. 2 0.876436 0.002689 10.90241 0.876189 -0.00025 -1. 3 0.876189 7.25E-07 10.89653 0.876189 -6.7E-08 -1.

first derivative at the root is: 10. second derivative at the root is: 23. proportionality constant = -1.094 <-- theoretical prediction

Task 2: Error Analysis

For Bisection:

0

2

n a (^) n

x E

For Newton Raphson: (^) , 1 2 ,

r t i t i r

f x E E f x

Interpretation Questions:

  1. For each algorithm, describe in words how the absolute approximate error changes from one iteration to the next.

For bisection, the size of the absolute approximate error is divided by 2 in every iteration. For Newton Raphson, the number of significant digits (almost) doubles in every iteration.

  1. Which of the two methods converges most quickly? Will this always be the case?

Newton Raphson clearly converges quickest in this case. After 3 iterations, its error is virtually zero (less than 1e-9), while bisection still has an error of 0.0625! This will not always be the case. We know that Newton Raphson may fail to converge or may converge very slowly if one does not start from an initial guess that is sufficiently close to the root.

  1. You may find slightly different values than the ones predicted by the equations. Explain why.

For Bisection, the predicted error is off by a factor 2. This is because we made slightly different assumptions. In the book (and in the lecture), we characterized the absolute approximate error in each iteration as the size of the bracket (x_upper – x_lower). In the table above, I used the formula that we introduced at the beginning of the semester, namely, that the absolute approximate error is equal to the current approximation minus the previous approximation. Since the current approximation is at the center of the bracket, this error is only half as big. (it is possible of course that you made the same assumption for both cases in which case the errors should have matched the prediction perfectly).

For Newton Raphson, we can compute a proportionality constant that relates the current error to the error squared in the previous iteration. This constant is: , 1 2 ,

t i (^) r t i r

E (^) f x C E f x

At the root, this evaluates to -1.094. As you can see in the table, the actual ratio of current error divided by previous error squared is close, but slightly different. This is due to the fact that the equation is only valid in the limit as the error goes to zero (in the first few iterations, the error is still pretty far from zero). In addition, the equation is expressed in terms of the true absolute error, while we are applying it in the table to the approximate absolute error.

Task 3: Interactive Exploration of the Bisection Algorithm Learn by exploring question 2: Is it possible to have a large relative error even when in the graphical window it looks like the root is found? If so, can you generate an example illustrating this?

Yes, it is possible when the true root is really close to zero. A small absolute error can then still result in a large relative error.

Another case, but one that cannot be illustrated with the Java applet is the case in which the function is discontinuous.

So, in conclusion, the bisection method will always find a root if the assumptions under which the algorithm was developed are satisfied: 1) the function is continuous, 2) we start from a valid bracket.

Learn by exploring question 4: How does the root finding algorithm behave when the curve has more than one root?

As long as we start from a valid bracket, the algorithm will converge to one of the roots, but it is not easy to predict in advance which one.

Task 4: Interactive Exploration of the False Position Algorithm Learn by exploring question 1: Create an example in which the false position algorithm converges very slowly to a root; preferably such that it does not even come near a root within the maximum of 8 iterations for the applet.

Learn by exploring question 4: Construct a curve with two roots. Does the false position algorithm converge? Explain. Does the method behave in the same way for all curves with two roots?

Having two roots requires that the initial interval is not a valid bracket. One could try to come up with a valid bracket by making one of the roots a double root, but then one should really count the double root as two roots meaning that we have three in total rather than two.

Task 5: Interactive Exploration of the Newton Raphson Algorithm Learn by exploring question 3: Construct two clearly distinct examples of a limit cycle.

In a first example the approximation jumps back and forth from one side of the root to the other. (it is very difficult to generate a case in which you have an exact limit cycle – something close is good enough. I was lucky when creating this example):

However, the algorithm will also converge to the root in one step when the function is a straight line. In this case, it will do so no matter what the initial guess is: