You are on page 1of 5

8/4/2014 C Program: Numerical Computing - Implementing the Newton Raphson Method - the learning point

http://www.thelearningpoint.net/computer-science/c-program-numerical-computing---implementing-the-newton-raphson-method 1/5
the learning point
Main Page Math Computer Science Physics And Its Applications Electrical & Electronic Engg.
Test Prep: IIT JEE/CBSE/ISC Programming Interviews English Grammar About Top ISC-ICSE Schools
Discussion Forums/Feedback Exam Result Analysis 2013 (CBSE/ICSE/JEE) The Book Corner
Computer Science >
C Program: Numerical Computing - Implementing the
Newton Raphson Method

0

Follow @learning_pt 115 followers


The C++ Programming
Language...
List Price: Rs.775
Our Price: Rs.736
The C++ Programming
Language (Bjarne
Stroustrup)
Beginning C++ Through Game
Pr...
Our Price: Rs.2008

Beginning C++ through
Game Programming

C++ How to Program
List Price: Rs.695
Our Price: Rs.632

C++: How to Program
(Deitel and Deitel
C Program to Reverse A String
C Program: Buil ding an Expression
Eval uator
C Program: Check f or Armstrong
Numbers
C Program: Check whether a string is a
Pal indrome or not
C Program: Common Operations on Sets
- Union, I ntersection, Dif f erence,
Cardinal Product
C Program: Computing exp(x), sin(x),
cos(x), tan(x) using series expansions
C Program: Computing the Area of a
Circl e
C Program: Computing the Upper
Triangul ar Matrix and Lower Triangul ar
Matrix
C Program: Demonstrating Fil e
Handl ing Functions
C Program: Demonstrating Operations
on Matrices - Addition, Subtraction,
Mul tipl ication, I nversion, Finding
Determinants
C Program: Demonstrating the use of
Bitwise Operators
C Program: Displ aying a Histogram of
word f requencies (unigram)
C Program: Distance Vector Routing
Al gorithm using Bel l man Ford' s
Al gorithm
C Program: Numerical Computing - The
Gaussian El imination Method
C Program: Numerical Computing -
I mpl ementing the Newton Raphson
Method
C Program: Numerical Computing - the
Bisection Method
C Program: Numerical Computing - The
Gaussian El imination Technique f rom
Linear Al gebra
C Program: Numerical Computing - the
Jacobi Method
C Program: Printing the Pascal Triangl e
C Program: Reversing the order of
Try out our Quizzes!
ICSE/ISC/CBSE Results:
2014
CBSE Percentage to
Percentile (2014)
Tabulation/Calculator
ISC-2014 Percentage to
Percentile Rankings
A Performance Analysis of
5346 CBSE Schools in the
Class 12 Examination of
2014 (More details and insights to
come soon. Totally, candidates from
8600 schools appeared for the CBSE
Class 12 Examination)
Top Performing ICSE and
ISC Schools - 2014
Mathematics
Quizzes on Progressions
MCQ Quiz #1: Arithmetic
Progression
MCQ Quiz #2: Geometric
Progression
MCQ Quiz #3 : More on
Geometric Progressions.
MCQ Quiz #4 : Harmonic
Progressions.
MCQ Quiz #5: More on Harmonic
Progression
MCQ Quiz #6: Mixed Progressions
Search this site
8/4/2014 C Program: Numerical Computing - Implementing the Newton Raphson Method - the learning point
http://www.thelearningpoint.net/computer-science/c-program-numerical-computing---implementing-the-newton-raphson-method 2/5

The C Programming
Language
List Price: Rs.175
Our Price: Rs.137

The C Programming
Language (Kernighan)

C How To Program 6th
Edition
List Price: Rs.650
Our Price: Rs.624


C How to Program
(Deitel and Deitel )

C Program implementing the
Newton Raphson Method
(Numerical Computing) for a
function
/*This program in C illustrates the Newton Raphson method.
This program calulate the approximation to the root of x*x-5.
The maximum error between 2 succesive approximation is taken as input from the user
alongwith the maximum number of iterations and the initial approximation.
*/
#include<stdio.h>
#include<math.h>
double F(double x)
{//our function
return ((x)*(x)-5);
}
double Fd(double x)
{//function's differentiation
return (2*(x));
}
int main()
{
double x0,h,err,root,x1;
int miter,iter;
printf("Enter the first approximation ,the max error and the maximum number of iterations\n");
scanf("%lf%lf%d",&x0,&err,&miter);
iter=1;
while(iter<=miter)
{
h=F(x0)/Fd(x0);//calculatinf f(x)/f'(x)as we do in Newton Raphson method
x1=x0-h;//x1=x0-f(x)/f'(x)
printf("The approximation's value after %d iteration is %.12lf\n",iter,x1);
if(fabs(h)<err)//If the difference between the 2 approximations is below the max error
{
root=x1;//then make the approximation as the root
words in a sentence
C Program: Sol ving Simul taneous
Equations in Two Variabl es
C Program: Source Code f or computing
the GCD(HFC) of two numbers
C Program: Source Code f or Sol ving
Quadratic Equations
C Program: Source code to sol ve the
Josephus Probl em
C Program: Sudoku Sol ver
C Program: The Usage of Command Line
Arguments
C Program: Using the Sieve of
Eratosthenes to print Prime Numbers
Coordinate Geometry - Straight
Lines
MCQ Quiz #1: Cartesian Planes
and the Straight Line- the Very
Basics
MCQ Quiz #2 on Straight Lines
MCQ Quiz #3 on Straight Lines
MCQ Quiz #4 on Straight Lines
Circles
1 MCQ Quiz #1 on Circles.
2 MCQ Quiz #2 on Circles.
3 MCQ Quiz #3 on Circles.
Conic Sections- Parabola,
Hyperbola, Ellipse
1 MCQ- The Basics of Conic
Sections
2 MCQ Quiz on Parabola. Your
score will be emailed to you.
3 MCQ Quiz (Fill up answers in
the Answer Submission form
below this)
4 MCQ Quiz/Worksheet on
Ellipses.

Probabil ity
MCQ Quiz #1 on Basic
Probability
MCQ Quiz #2: More Challenging
Problems on Probability
MCQ Quiz #3- Conditional
Probability and Bayes Theorem
Complex Numbers
MCQ Quiz #1
MCQ Quiz #2: More on Complex
Numbers
Quadratic Equations
MCQ Quiz for Quadratic
Equations- test how much you
know about the topic !
Quadratic In-equations
MCQ Quiz for Quadratic In-
equations
Computer Science
Quizzes on Basic Object Oriented
Programming with C++
1 MCQ Quiz #1: C++ and OOPS
2 MCQ Quiz #2: Inheritance in
C++
Quizzes on C Programming- Arrays,
8/4/2014 C Program: Numerical Computing - Implementing the Newton Raphson Method - the learning point
http://www.thelearningpoint.net/computer-science/c-program-numerical-computing---implementing-the-newton-raphson-method 3/5
Log In
Recommendations
Log in to Facebook to see your f riends'
recommendations.
C Program: Computing the Upper Triangular
Matrix and Lower Triangular Matrix - the
learning point
2 people recommend this.
MCQ Quizzes- Test your C Programming
skills!: Quiz questions on Strings, Arrays,
Pointers - the learning point
Be the f irst of your f riends to recommend this.
Data Structures: Stacks ( with C Program
source code) - the learning point
19 people recommend this.
About - the learning point
Be the f irst of your f riends to recommend this.
Top ICSE-ISC Schools Based on Academic
Performance (Based on Otherwise Insider
Information - Courtesy: Electronic Data
Mining) - the learning point
2 people recommend this.
Linear Algebra - Matrices Part I - A Tutorial
with Examples - the learning point
2 people recommend this.
Facebook social plugin
break;
}
else
x0=x1;
iter++;
}
if(root==x1)
{//display root and the function value
printf("The root is: %.12lf\n",root);
double fncvalue = F(root);
printf("Value of F(root) is: %.12lf",fncvalue);
}
else
printf("The unsufficent number of iteration");//In case root!=x1 then number of iteration were insufficient
getch();
}
/*A sample run of thje program was carried out and the results were found to be as:-
Enter the first approximation ,the max error and the maximum number of iterations
2
0.0000000001
7
The approximation's value after 1 iteration is 2.250000000000
The approximation's value after 2 iteration is 2.236111111111
The approximation's value after 3 iteration is 2.236067977916
The approximation's value after 4 iteration is 2.236067977500
The approximation's value after 5 iteration is 2.236067977500
The root is: 2.236067977500
Value of F(root) is: 0.000000000000
*/

Strings and Pointers
1 C Programming MCQ Quiz #1:
Strings- 1
2 C Programming MCQ Quiz #2:
Strings (2)
3 C Programming MCQ Quiz #3:
Strings (3)
4 C Programming MCQ Quiz #4:
Arrays(1)
5 C Programming MCQ Quiz #5:
Arrays (2)
6 C Programming MCQ Quiz #6:
Arrays (3)
7 C Programming MCQ Quiz #7:
Pointers (1)
8 C Programming MCQ Quiz #8:
Pointers (2)
Quizzes on Java Programming
1 Java MCQ Quiz #1- Classes,
Inheritances and Interfaces
2 Java MCQ Quiz #2-
Collections
3 Java MCQ Quiz #3- Threading
Quizzes on Data Structures,
Algorithms and Complexity
1 MCQ Quiz #1: The Basics of
Sorting Algorithms- Quadratic
Sorts
2 MCQ Quiz #2: Efficient Sorting
Algorithms- Quick sort, Merge
Sort, Heap Sort
3 MCQ Quiz #3- The Radix Sort
4 MCQ Quiz #4: Divide and
Conquer Techniques- Binary
Search, Quicksort, Merge sort,
Complexities
5 MCQ Quiz #5- Dynamic
Programming
6 MCQ Quiz #6- Complexity of
Algorithms
7 MCQ Quiz #7- Application of
Master's Theorem
8 MCQ Quiz #8: Binary Search
Trees
9 MCQ Quiz #9: B-Trees
10 MCQ Quiz #9: AVL-Trees
11 MCQ Quiz #10: Representing
Graphs as Data Structures
12 MCQ Quiz #11: Spanning
Trees
13 MCQ Quiz #12: Algorithms -
Graphs: Spanning Trees - Kruskal
and Prim Algorithms
14 MCQ Quiz #13: Algorithms -
Graphs: Depth and Breadth First
Search
8/4/2014 C Program: Numerical Computing - Implementing the Newton Raphson Method - the learning point
http://www.thelearningpoint.net/computer-science/c-program-numerical-computing---implementing-the-newton-raphson-method 4/5
Revolting Facts About McDonald's
Big Mac. Did You Know?
10 ideas for a great first date
You won't believe what this airline
did with his luggage!
Adverti sement

0
HTML Comment Box is loading comments...
Basi c Engli sh Grammar
Test your English Online: Articles
(Quiz #1)
Test Your English Online: Articles
(Quiz #2)
Test Your English Online: Articles
(Quiz #3)
English Grammar- The Tenses:
Quiz #1
English Grammar- The Tenses:
Quiz #2
English Grammar- The Tenses:
Quiz #3
English Grammar- The Tenses:
Quiz #4
English Grammar- The Tenses:
Quiz #5
Test Your English Grammar: The
Parts of Speech (Quiz #1)
Test Your English Grammar: The
Parts of Speech (Quiz #2)
Test Your English Grammar: The
Parts of Speech (Quiz #3)
Test Your English Grammar: The
Parts of Speech (Quiz #4)
Test Your English Grammar: The
Parts of Speech (Quiz #5)
Test Your English Grammar: The
Parts of Speech (Quiz #6)
Test Your English Grammar: The
Parts of Speech (Quiz #7)
Test Your English Grammar: The
Parts of Speech (Quiz #8)
Test Your English Grammar: The
Parts of Speech (Quiz #9)
Test Your English Grammar: The
Parts of Speech (Quiz #10)
PhotoBlog - Random pictures from random travels
8/4/2014 C Program: Numerical Computing - Implementing the Newton Raphson Method - the learning point
http://www.thelearningpoint.net/computer-science/c-program-numerical-computing---implementing-the-newton-raphson-method 5/5
Sign in | Recent Site Activity | Report Abuse | Print Page | Powered By Google Sites