ccodechamp com c program of newton raphson method c code cha

7
pdfcrowd.com open in browser PRO version Are you a developer? Try out the HTML to PDF API C program of Newton Raphson Method | C code champ MR CODER AUGUST 20, 2012 4 C program of Newton Raphson Method : Newton Raphson method is a method of approximating a root of the polynomial equation also called the method of tangents. In Newton’s method, the initial (“first”) approximation x = a 1 is used to find a second, more accurate, approximation by drawing the tangent to the graph of y = f(x) at the point A[a 1 , f(a 1 )] up to the intersection of the tangent with the x-axis. The point of intersection is x = a 1 f(a 1 )/ f ’(a 1 ) and is adopted as the new value a 2 of the root. By repeating this process as necessary, we can obtain Search here.. +2 Recommend this on Google Ccodechamp on Facebook Like Home C Programs C Compiler C Tutorials Mathematics Algorithms Windows Programming

Upload: lokesh-singh

Post on 18-Apr-2015

183 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Ccodechamp Com c Program of Newton Raphson Method c Code Cha

pdfcrowd.comopen in browser PRO version Are you a developer? Try out the HTML to PDF API

C program of Newton Raphson Method | C code champMR CODER AUGUST 20, 2012 4

C program of Newton Raphson Method :Newton Raphson method is a method ofapproximating a root of the polynomial equationalso called the method of tangents. In Newton’smethod, the initial (“first”) approximation x = a1 is

used to find a second, more accurate,approximation by drawing the tangent to the graphof y = f(x) at the point A[a1, f(a1)] up to the

intersection of the tangent with the x-axis. Thepoint of intersection is

x = a1 – f(a1)/f’(a1)

and is adopted as the new value a2 of the root. By repeating this process as necessary, we can obtain

Search here..

+2 Recommend this on Google

Ccodechamp on Facebook

Like

Home C Programs C Compiler C Tutorials Mathematics Algorithms Windows Programming

Page 2: Ccodechamp Com c Program of Newton Raphson Method c Code Cha

pdfcrowd.comopen in browser PRO version Are you a developer? Try out the HTML to PDF API

increasingly accurate approximations a2, a3, … of the root provided that the derivative f’(x) is monotonic and

preserves its sign on the segment containing root.

How to use the C program :

Consider an example : f(x) = x 2̂ - 4 as our polynomial equation. We want to calculate its root and sayfirst approximation =6. Then maximum power of X = 2, coefficients of x 0̂ = -4, x 1̂ = 0, x 2̂ = 1 & firstapproximation =6. Now C program of Newton Raphson Method will display the iterations and root of thepolynomial as output.

C program of Newton Raphson Method :

P riyank NizamudheenP rashant P rashmita Junaid Shashank

55 people like Ccodechamp.

Facebook soc ial plugin

Enter your email address to subscribe:

Subscribe

Categories

Select Category

Sitemap

August 2012 (51)

#include<conio.h>#include<stdio.h>#include<stdlib.h>#include<math.h> int max_power,i=0,cnt=0,flag=0;int coef[10]={0};float x1=0,x2=0,t=0;float fx1=0,fdx1=0; int main(){ printf("-----------------------------------------------------------\n"); printf("----------------------Made by C code champ-----------------\n"); printf("-----------------------------------------------------------\n\n"); printf("\n\n\t C PROGRAM FOR NEWTON RAPHSON METHOD"); printf("\n\n\n\tENTER THE MAXIMUM POWER OF X = "); scanf("%d",&max_power); for(i=0;i<=max_power;i++) { printf("\n\t x^%d = ",i); scanf("%d",&coef[i]); } printf("\n"); printf("\n\tTHE POLYNOMIAL IS = "); for(i=max_power;i>=0;i--)/*printing coefficients*/ { printf(" %dx^%d",coef[i],i); }

Page 3: Ccodechamp Com c Program of Newton Raphson Method c Code Cha

pdfcrowd.comopen in browser PRO version Are you a developer? Try out the HTML to PDF API

TAGS » algorithms in C, C code of New ton Raphson Method, C program of New ton Raphson Method, C programs, New tonRaphson in C, New ton Raphson Method in C

POSTED IN » Algorithms, C Programs, Equations, Mathematics

View all posts by Mr Coder

We hope that you all have enjoyed the C program of Newton Raphson Method. If you have any doubtsrelated to the program ask us in form of comments.

About the author: Mr Coder

Well, I am application developer in Tata Consultancy Services and love to code. My hobbies is to doHacking, Coding, Blogging, Web Designing and playing online games. Feel free to contact me [email protected] or [email protected]

printf("\n\n\tFirst approximation x1 ----> "); scanf("%f",&x1); printf("\n\n-----------------------------------------------------------\n"); printf("\n ITERATION \t x1 \t F(x1) \t \tF'(x1) "); printf("\n-----------------------------------------------------------\n"); do { cnt++; fx1=fdx1=0; for(i=max_power;i>=1;i--) { fx1+=coef[i] * (pow(x1,i)) ; } fx1+=coef[0]; for(i=max_power;i>=0;i--) { fdx1+=coef[i]* (i*pow(x1,(i-1))); } t=x2; x2=(x1-(fx1/fdx1)); x1=x2; printf("\n\t %d \t%.3f \t %.3f\t\t%.3f ",cnt,x2,fx1,fdx1); }while((fabs(t - x1))>=0.0001); printf("\n\n\n\t THE ROOT OF EQUATION IS = %f",x2); getch();}

Page 4: Ccodechamp Com c Program of Newton Raphson Method c Code Cha

pdfcrowd.comopen in browser PRO version Are you a developer? Try out the HTML to PDF API

Related Articles»C program to print reverse pyramid of alphabetsC program to Print Pascal Triangle | C code champC code to draw pyramid using stars | C code champC program of Newton Backward Interpolation FormulaC program of Booth’s multiplication algorithmC program of Bubble sort using linked listC program of Knapsack problem using BacktrackingC program for Travelling Salesman Problem using Branch and BoundC program to find determinant of Matrix | C code champC program of Travelling Salesman ProblemC program of Regula Falsi method to find rootC program of Hopfield Networks | C code champC program of Shell Sort Algorithm | C code champC program for Radix Sort AlgorithmC program for Pigeonhole Sort Algorithm | C code champC program of Pancake Sort Algorithm | C code champC program for Insertion Sort AlgorithmC program of Heap Sort Algorithm | C code champC program of Gnome Sort Algorithm | C code champC program for Counting Sort AlgorithmC program for Comb Sort Algorithm | C code champC program for Cocktail Sort algorithm | C code champC program for quick sort algorithmC program for Bucket sort algorithm

Page 6: Ccodechamp Com c Program of Newton Raphson Method c Code Cha

pdfcrowd.comopen in browser PRO version Are you a developer? Try out the HTML to PDF API

Comment

Post Comment

Recent Articles

C program to print reverse pyramid of alphabets

Download Turbo C++ for Windows 7 Full screenbug fixed

C program to Print Pascal Triangle | C code champ

C code to draw pyramid using stars | C codechamp

C program of Newton Backward InterpolationFormula

C program of Booth’s multiplication algorithm

Latest Feeds

C program to print reverse pyramid of alphabets

Download Turbo C++ for Windows 7 Full screenbug fixed

C program to Print Pascal Triangle | C code champ

C code to draw pyramid using stars | C codechamp

C program of Newton Backward InterpolationFormula

C program of Booth’s multiplication algorithm

Recent Comments

download windows 7 on How to install Turbo CCompiler in Windows

Tester on C program of Newton BackwardInterpolation Formula

Mr Coder on C program of Newton RaphsonMethod | C code champ

collectiva on C program of Newton RaphsonMethod | C code champ

Mr Coder on C program of Newton RaphsonMethod | C code champ

Page 7: Ccodechamp Com c Program of Newton Raphson Method c Code Cha

pdfcrowd.comopen in browser PRO version Are you a developer? Try out the HTML to PDF API

Copyright © 2011 -CCodeChamp. All rights reserved. Powered by C code champ Back to Top