DOC PREVIEW
IIT MATH 149 - Newtons method

This preview shows page 1-2 out of 5 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 5 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 5 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 5 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Newton’s methodIntroductionIn this laboratory we will become familiar with Newton's method for attaining successive approximations to the zero of a func-tion. Newton’s method is also known as the Newton-Raphson method. The While and For loop statements for the repeti-tive execution of code, as well as the Print command, will be used. Successive approximations will also be illustratedgraphically.Newton's method is a technique for approximating the zeros of a function. It is based on the observation that, in most cases, if wemake a fairly good initial guess, say x0, to the zero of a function, f , then the x-intercept of the tangent line to the graph of f atx0, f x0 called x1, is a better estimate of the zero than was x0. Repeating this process n times, we find that the (n + 1)stapproximation is given by:xn+1= xn-f xnf'xn.ExamplesExample 1 is based on prior Math 149 Maple laboratories. Example 2 was created in Mathematica for Math 151.ü Example 1Find all numbers x in the interval 0, 1 for which cos3 p x22= x.To determine the number of solutions to this problem, we plot a graph of the functionsFx =cos3 p x22 and Gx = x for 0 < x < 1. Then the solutions to this problem are all the values of x at which Fx = Gx . In[1]:=funcFx_ : Cos3  Pi  x  2 ^2funcGx_ : xIt is also evident that the solutions to our problem are the zeros of the function f x = Gx - Fx.We plot a graph of the functions f , F, and G to illustrate our remark.In[3]:=fx_ : funcGx  funcFxPlotfuncFx, funcGx,fx, x, 0, 1, PlotStyle  Red, Blue, GreenOut[4]=0.2 0.4 0.6 0.8 1.0-1.0-0.50.51.0We can see that there are three points of intersection: one near 0.25, one near 0.5 and one near 0.75.In order to estimate these three zeros of f in the interval 0, 1 using Newton's method, we begin by defining a function newton,which will be used to compute the successive approximations. This function corresponds to the formula for the Newton iterationmentioned in the Introduction.In[5]:=newtonx_ : x  fxf'xIf we iterate with this function, then the iteration does not remember all intermediate values xn, but instead constantly overwritesthe value of x as soon as a better approximate solution has been found (see the line xn=newton[xn] in the code below).Note that if you insist on using the D operator for the definition of the derivative term in the newton function, then you need toseparate the two steps of differentiation and evaluation, i.e., you would have to define newton like this:newton[x_] := t - f[t]/D[f[t], t] /. t Ø xThe following code iterates Newton's method until we have found an x for which f x is less than 10-10 in absolute value (seethe While[] statement below). The commands PaddedForm and NumberForm are used to format the computed numbers nicely.In[6]:=xn  0.25;  our initial guess Print"x0", PaddedFormxn, 12, 12,", fx0", NumberFormfxn,12;k  0;  a counter WhileAbsfxn  10^10,xn  newtonxn;k  k  1;Print"x"k,"", PaddedFormxn, 12, 12,", f", "x"k,"", NumberFormfxn,12;x0 0.250000000000, fx00.103553390593x1 0.226096603561, fx10.00826202284178x2 0.227751553321, fx20.0000325802639608x3 0.227758131503, fx35.23180249123  1010x4 0.227758131609, fx41.11022302463  1016Thus, it appears that the first zero of f in the interval 0, 1 has value x = 0.2277581316 when rounded to ten decimal places.The second zero in the interval 0, 1 is approximately x = 0.5. 2 Newtons method.nbIn fact, this value is exactly 0.5, since 12= Cos3 p42.To approximate the final zero of f in 0, 1, we make an initial guess using the graph of f created earlier as a reference and applyNewton's method to obtain the successive approximations. Taking x0= 0.75 we obtain successive estimates similar as before.In[12]:=xn  0.75;  our initial guess Print"x0", PaddedFormxn, 12, 12,", fx0", NumberFormfxn,12;k  0;  a counter WhileAbsfxn  10^10,xn  newtonxn;k  k  1;Print"x"k,"", PaddedFormxn, 12, 12,", f", "x"k,"", NumberFormfxn,12;x0 0.750000000000, fx00.103553390593x1 0.773903396439, fx10.00826202284179x2 0.772248446679, fx20.0000325802639608x3 0.772241868497, fx35.23180165857  1010x4 0.772241868391, fx40.The short nested list version is given bySo the final zero rounded to ten decimal places is x = 0.7722418684.In the following example Newton's method is illustrated graphically.ü Example 2Estimate all roots of the third degree polynomial function px = x3- 4 x - 1. We begin by graphing the polynomial y = px in the plane.In[18]:=px_ : x3 4  x  1Plotpx, x,  3, 3, PlotStyle  BlueOut[19]=-3 -2 -1 1 2 3-15-10-5510Newtons method.nb 3Clearly, p has exactly three real zeros. Let's use Newton's method, as before, to estimate these roots. Suppose we set x0= 1.As in Example 1, we use a function newton to obtain succesive estimates:In[20]:=newtonx_ : x  pxp'xIn[21]:=xn  1.0;  our initial guess Print"x0", PaddedFormxn, 12, 12,", px0", NumberFormpxn,12;k  0;  a counter WhileAbspxn  10^10,xn  newtonxn;k  k  1;Print"x"k,"", PaddedFormxn, 12, 12,", p", "x"k,"", NumberFormpxn,12;x0 1.000000000000, px04.x13.000000000000, px116.x22.304347826090, px24.01873921262x31.967489476620, px30.74622305627x41.869470470670, px40.0557675569007x51.860870682710, px50.000414141645534x61.860805856780, px62.34600978644  108x71.860805853110, px70.Although our starting value of x0= 1 was between the largest two of the three roots, Newton’s method has converged to


View Full Document

IIT MATH 149 - Newtons method

Documents in this Course
QUIZ

QUIZ

2 pages

QUIZ

QUIZ

3 pages

Quiz

Quiz

2 pages

Exam

Exam

4 pages

Load more
Download Newtons method
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Newtons method and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Newtons method 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?