0% found this document useful (0 votes)
11 views5 pages

Newton Method

Uploaded by

alaska112000
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views5 pages

Newton Method

Uploaded by

alaska112000
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

In[633]:=

(* newton method*)
f[x_] := x ^ 2 - 4x + 1
a = 0;
b = 1;
nmax = 10;
l = {};

Plotf[x], x, a - 2, b + 2, PlotRange → All, GridLines → Automatic


Fori = 1, i ≤ nmax, i ++,
c = Nb - f[b]  f '[b];
b = c;
l = Appendl, i, N[c], N[f[c]];
TableForml,
TableHeadings → None, "Iteration", "Root of the Equation", "Function Value",
TableAlignments → Center

Out[638]=

10

-2 -1 1 2 3

Out[640]//TableForm=
Iteration Root of the Equation Function Value
1 0. 1.
2 0.25 0.0625
3 0.267857 0.000318878
4 0.267949 8.47267 × 10-9
5 0.267949 0.
6 0.267949 0.
7 0.267949 0.
8 0.267949 0.
9 0.267949 0.
10 0.267949 0.
2

In[641]:=
f[x_] := x ^ 3 - 2 x ^ 2 + 1
a = 0;
b = 6;
nmax = 10;
l = {};

Plotf[x], x, a - 2, b + 2, PlotRange → All, GridLines → Automatic


Fori = 1, i ≤ nmax, i ++,
c = Nb - f[b]  f '[b];
b = c;
l = Appendl, i, N[c], N[f[c]];
TableForml,
TableHeadings → None, "Iteration", "Root of the Equation", "Function Value",
TableAlignments → Center

Out[646]=
400

300

200

100

-2 2 4 6 8

Out[648]//TableForm=
Iteration Root of the Equation Function Value
1 4.27381 42.5321
2 3.14567 12.3367
3 2.42435 3.49414
4 1.98401 0.937069
5 1.74206 0.2172
6 1.64037 0.0323056
7 1.61899 0.00132556
8 1.61804 2.60698 × 10-6
9 1.61803 1.01563 × 10-11
10 1.61803 0.
3

In[649]:=
f[x_] := x ^ 2 - 4x + 1
a = - 3;

b = 3;
nmax = 10;
l = {};

Plotf[x], x, a - 2, b + 2, PlotRange → All, GridLines → Automatic


Fori = 1, i ≤ nmax, i ++,
c = Nb - f[b]  f '[b];
b = c;
l = Appendl, i, N[c], N[f[c]];
TableForml,
TableHeadings → None, "Iteration", "Root of the Equation", "Function Value",
TableAlignments → Center

Out[654]=

40

30

20

10

-4 -2 2 4

Out[656]//TableForm=
Iteration Root of the Equation Function Value
1 4. 1.
2 3.75 0.0625
3 3.73214 0.000318878
4 3.73205 8.47268 × 10-9
5 3.73205 0.
6 3.73205 0.
7 3.73205 0.
8 3.73205 0.
9 3.73205 0.
10 3.73205 0.
4

In[657]:=
f[x_] := x ^ 2 + 3x+4
a = - 20;

b = 10;
nmax = 10;
l = {};

Plotf[x], x, a - 2, b + 2, PlotRange → All, GridLines → Automatic


Fori = 1, i ≤ nmax, i ++,
c = Nb - f[b]  f '[b];
b = c;
l = Appendl, i, N[c], N[f[c]];
TableForml,
TableHeadings → None, "Iteration", "Root of the Equation", "Function Value",
TableAlignments → Center

Out[662]=

400

300

200

100

-20 -15 -10 -5 5 10

Out[664]//TableForm=
Iteration Root of the Equation Function Value
1 4.17391 33.9433
2 1.18274 8.9471
3 - 0.484788 2.78066
4 - 1.85428 1.87552
5 0.792637 7.00619
6 - 0.735338 2.33471
7 - 2.26197 2.33059
8 - 0.732636 2.33885
9 - 2.25659 2.32242
10 - 0.721781 2.35563
5

In[665]:=
f[x_] := x ^ 3 - 5x + 1
a = - 5;

b = 10;
nmax = 10;
l = {};

Plotf[x], x, a - 2, b + 2, PlotRange → All, GridLines → Automatic


Fori = 1, i ≤ nmax, i ++,
c = Nb - f[b]  f '[b];
b = c;
l = Appendl, i, N[c], N[f[c]];
TableForml,
TableHeadings → None, "Iteration", "Root of the Equation", "Function Value",
TableAlignments → Center

Out[670]=

1500

1000

500

-5 5 10

Out[672]//TableForm=
Iteration Root of the Equation Function Value
1 6.77627 278.27
2 4.68013 80.111
3 3.36058 22.1497
4 2.59363 5.479
5 2.23271 0.966536
6 2.13562 0.0622248
7 2.12846 0.000328686
8 2.12842 9.34672 × 10-9
9 2.12842 3.55271 × 10-15
10 2.12842 - 1.77636 × 10-15

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy