



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
How to use newton's method to find the root of a given function. It includes examples using mathematica and graphical illustrations. The process involves finding the intersection of the tangent line with the x-axis and repeating the process with the new point.
Typology: Study notes
1 / 6
This page cannot be seen from the preview
Don't miss anything!




In[1]:= f^ =^ Exp @ x D^ +^ x^ -^ 3; Plot @ f, 8 x, - 4, 4 <D
Out[2]=
10
20
30
In[3]:= df = D @ f, x D ; slope = df ê. x Æ x0; y0 = f ê. x Æ x0; tangentline = slope *** H** x - x0 L + y
Out[6]= -^3 + „x0^ +^ I^1 + „x0M Hx^ -^ x0L^ +^ x
In[7]:= plotf = Plot @ f, 8 x, 0, 2.5 <D ; plotp0 = Graphics @8 Red, Dashed, Line @88 2, 0 < , 8 2, f ê. x Æ 2 <<D < D ; tangentline0 = tangentline ê. x0 Æ 2 plott0 = Plot @ tangentline0, 8 x, 0, 2 < , PlotStyle Æ 8 Red <D ; Show @ plotf, plotp0, plott0 D
Out[9]= -^1 + „^2 +^ I^1 + „^2 M H-^2 +^ xL
Out[11]=
0.5 1.0 1.5 2.0 2.
2
4
6
8
10
In[12]:= NSolve @ tangentline0^ ä^ 0,^ x D
Out[12]= 88 x^ Æ^ 1.23841<<
In[13]:= plotp1^ =^ Graphics @8 Green,^ Dashed,^ Line @88 1.23841, 0 < ,^^8 1.23841,^ f^ ê. x^ Æ^ 1.23841 <<D < D ; tangentline1 = tangentline ê. x0 Æ 1. plott1 = Plot @ tangentline1, 8 x, 0, 1.23841 < , PlotStyle Æ 8 Green <D ; Show @ plotf, plotp0, plott0, plotp1, plott1 D
Out[14]= 1.68853 + 4.45012 H-1.23841 + xL
Out[16]=
0.5 1.0 1.5 2.0 2.
2
4
6
8
10
In[23]:= NewtonsMethodList @ f _ ,^^8 x _ , x0 _< , n _D^ : = N @ NestList @ - Function @ x, f D@D ê Derivative @ 1 D@ Function @ x, f DD@D &, x0, n DD
In[24]:= values^ =^ NewtonsMethodList @ Exp @ x D^ +^ x^ -^ 3,^^8 x, 2 < ,^5 D
Out[24]= 8 2., 1.23841, 0.858974, 0.793598, 0.792061, 0.79206<
In[25]:= Show @8 plotf, Table @ Plot @ tangentline,^^8 x,^ - 1, x0 < , PlotStyle^ Æ^8 Hue @ x0^ ê^^2 D<D ,^^8 x0, values <D , Table @ Graphics @8 Hue @ x0 ê 2 D , Dashed, Line @88 x0, 0 < , 8 x0, f ê. x Æ x0 <<D < D , 8 x0, values <D<D
Out[25]=
0.5 1.0 1.5 2.0 2.
2
4
6
8
10
In[26]:= FindRoot @ Exp @ x D^ +^ x^ -^^3 ä^ 0,^^8 x, 2 <D
Out[26]= 8 x^ Æ^ 0.79206<
Example : Choosing the first point is sometimes important.
In[27]:= f = x ^ 3 - 2 ***** x + 2; plotf = Plot @ f, 8 x, - 3, 3 <D tangentline = H D @ f, x D ê. x Æ x0 L * H x - x0 L + H f ê. x Æ x0 L ;
Out[28]=
5
10
In[30]:= values^ =^ NewtonsMethodList @ x ^ 3^ -^^2 *****^ x^ +^ 2,^^8 x,^ -^3 < ,^5 D Show @8 plotf, Table @ Plot @ tangentline, 8 x, - 1, x0 < , PlotStyle Æ 8 Hue @ x0 ê 2 D<D , 8 x0, values <D , Table @ Graphics @8 Hue @ x0 ê 2 D , Dashed, Line @88 x0, 0 < , 8 x0, f ê. x Æ x0 <<D < D , 8 x0, values <D< , PlotRange Æ 88 - 3, - 1.5 < , 8 - 10, 1 <<D
Out[30]= 8 - 3.,^ - 2.24,^ - 1.87537,^ - 1.77656,^ - 1.76933,^ - 1.76929<
Out[31]=