0% found this document useful (0 votes)
7 views2 pages

Newton-Raphson Root Finding Method

The document describes a procedure for finding the root of a user-defined function using the Newton-Raphson method. It includes steps for plotting the function, checking if the root exists within a specified interval, and iteratively calculating the root until a prescribed tolerance or maximum iterations are reached. An example function is provided, along with the results of several iterations showing the convergence to the root.

Uploaded by

hetankumar9
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)
7 views2 pages

Newton-Raphson Root Finding Method

The document describes a procedure for finding the root of a user-defined function using the Newton-Raphson method. It includes steps for plotting the function, checking if the root exists within a specified interval, and iteratively calculating the root until a prescribed tolerance or maximum iterations are reached. An example function is provided, along with the results of several iterations showing the convergence to the root.

Uploaded by

hetankumar9
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

In[1]:= Print["f(x)= ", f[x_] = Input["Enter the function :"]];

Print["Graph of the fuction in the interval[-4,4]"];


Plot[f[x], {x, -4, 4}]
a = Input["Enter the value of a:"];
b = Input["Enter the value of b:"];
If[f[a] * f[b] > 0, Print["THe given interval doesn't contain the root"];
Exit[]];
ϵ = Input["Enter the prescribed tolerance error:"];
k = Input["Enter the maximum number of iterations:"];
Print["Graph of the function in the interval [", a, "," b, "]"]
Plot[f[x], {x, a, b}]
x0 = N[(a + b) / 2];
For[i = 1, i ≤ k, i ++,
{
If[f '[x0]  0, Break[]],
x1 = N[x0 - f[x0] / f '[x0]],
Print["The Root after iteration", i, "is", x1],
If[Abs[f[x1]] < ϵ, Break[]],
x0 = x1
}
]

f(x)= -5 - 17 x + 5 x2 + x3

Graph of the fuction in the interval[-4,4]

80

60

40

Out[3]=

20

-4 -2 2 4

-20

Graph of the function in the interval [13 ,]


2 Newton [Link]

Out[10]=

15

10

1.5 2.0 2.5 3.0

-5

-10

-15

The Root after iteration1is2.73333

The Root after iteration2is2.54064

The Root after iteration3is2.52325

The Root after iteration4is2.52311

You might also like