0% found this document useful (0 votes)
603 views4 pages

Newton Raphson Method

This document describes the Newton Raphson method for finding the root of an equation by iteratively approximating the root. It provides an algorithm for the method along with sample code to implement the Newton Raphson method to find the root of the equation f(x)=x^3-(8x)-4. The discussion notes that the initial approximation must be close to the root for the method to converge and discusses limitations of the specific code provided.

Uploaded by

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

Newton Raphson Method

This document describes the Newton Raphson method for finding the root of an equation by iteratively approximating the root. It provides an algorithm for the method along with sample code to implement the Newton Raphson method to find the root of the equation f(x)=x^3-(8x)-4. The discussion notes that the initial approximation must be close to the root for the method to converge and discusses limitations of the specific code provided.

Uploaded by

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

15

ASSIGNMENT 4
TO COMPUTE ROOT OF AN EQUATION BY USING NEWTON
RAPHSON METHOD

STATEMENT:

‘Newton Raphson’ method is an iterative method and is used to find isolated roots of an equation
f(x)=0. The object of this method is to correct the approximate root x0 (say) successively to its exact
value α. Initially , a crude approximation small interval [a0 , b0] is found out in which only one root α
(say) of f(x)=0 lies.
In this method:
𝑓(𝑥0 )
𝑥𝑛+1 = 𝑥0 −
𝑓′(𝑥0 )

ALGORITHM:

INPUT: An equation F(x)= x3 −(8x) – 4 and it’s derivative


E(x)= 3x2 − 8
OUTPUT: An isolated root xn

PROCESS:

Step 1: The equation and it’s derivative defined by ‘macro’ F(x) and E(x)
Respectively.

Step 2: Create the function “void main()”


16

[‘a’ and ‘b’ are two float type variables and initially a=0.0 and b=1.0]
Step 2.1: While (F(a)*F(b) > 0) then repeat Step 2.2 to Step 2.3

Step 2.2: Set a  b

Step 2.3: Set b  b+1.0


[End of Step 2.1 ‘While’ loop]

Step 2.4: Display the two integer values ‘a’ and ‘b’ in which the root lies i.e.
print “a,b”.

Step 2.5: Take the value of Error in a float type variable ‘err’.

Step 2.6: Set s  a

Step 2.7: Do Step 2.8 to Step 2.14

Step 2.8: Set p  s

Step 2.9: Set m  F(p)

Step 2.10: Set n  E(p)

Step 2.11: Set h  −(m/n)

Step 2.12: Set s  p+h

Step 2.13: Print “m,n,h,s”

Step 2.14: While (fabs(s-p)>err) then go to Step 2.7 repeatedly

[End of Step 2.7 ‘do-while’ loop]

Step 2.15: Display the value of the root correct up to 4 decimal places i.e. print “s”

[End of the function “void main()”].

Step 3: Stop

PROGRAM CODE:

#include<stdio.h>
#include<conio.h>
#include<math.h>
#define F(x) (((x)*(x)*(x))-(8*(x))-4)
#define E(x) ((3*(x)*(x))-8)
17

void main( )
{
float a=0.0,b=1.0,s=0.0,h,m,n,p=0.0,err;
while(F(a)*F(b)>0)
{
a=b;
b=b+1.0;
}

printf("\n Lower bound and upper bound: %f and %f",a,b);


printf("\n\n Enter error: ");
scanf("%f",&err);
printf("\n\n f(xn) f'(xn) h x(n+1)\n");
printf("\n -----------------------------------------------------\n");
s=a;

do
{
p=s;
m=F(p);
n=E(p);
h=-(m/n);
s=p+h;
printf(" %f %f %f %f\n",m,n,h,s);
} while(fabs(s-p) > err);
printf("\n -----------------------------------------------------\n");
printf("\n\n Ans: %.4f(correct upto 4 decimal places)",s);

getch( );
}

PROGRAM OUTPUT:
18

DISCUSSION:

If Єn be a tolerable error, we should terminate the iteration when |xn+1−xn| ≤Єn. Newton Raphson
Method fails when, f’(x)=0 or very small in the neighbourhood of the root. If the initial
approximation is very close to the root , then the convergence in Newton-Raphson Method is faster
than the iteration method. The initial approximation must be taken very close to the root, otherwise
the iterations may diverge. This program is not flexible i.e this program is only for the particular
function f(x)=x3−9x+1. We can not use this program to find the root of any other function.

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