Skip to main content
Home
Live to Learn!

Main navigation

  • Home
  • Learn
    • FoxPro
    • MS-DOS
    • C PRG
    • Java
    • ASP
    • Ruby on Rails
    • ASP.NET
    • E-Books
    • Exam Preparation
    • Tools
  • Blog
  • Forums
  • Contact
User account menu
  • Log in

Breadcrumb

  1. Home
  2. C Programming

Newton Raphson Method

Book navigation

  • C Programming Introduction
  • C – Program Code – Basics Part I
  • C – Program Code – Basics Part II
  • Operators in C Programming
  • C – Program Code – Basics Part III
  • C Program Code Basics - Part IV
  • Addition , Subtraction and Multiplication of Matrices
  • Solving Quadratic Equation
  • Sum of sin series
  • Sum of cos series
  • Sum of e series
  • Ascending and Descending order
  • Sorting in Alphabetical Order
  • Factorial of a number
  • Fibonacci Series
  • String Counting
  • String Manipulation
  • Bisection Method
  • Newton Raphson Method
  • Lagrange's Interpolation
By Karthikeyan , 8 September, 2009

Sample C program that uses Newton Raphson Method in mathematics


/*Newton Raphson Method*/
#include
#include 
float f1(x)
float x;
{
	return(x*x*x-6*x+4);
}
float f2(x)
float x;
{
	return(3*x*x-6);
}
main()
{
    int i;
	float v1, v2, x0, x1, w, z, e, k;
	clrscr();
    printf("\n\t Newton - Raphson Method");
    printf("\n\t************************");
	v1 =0.0; v2 =1.0;
    do
    {
		w  = f1(v1);
		z  = f1(v2);
		v2 = v2+1.0;
    }
    while(((w>0.0) && (z<0.0)) || ((w<0.0) && (z==0.0)));
	x0 = v1;
	printf("\n\n\t The given function is: x^3 - 6x +4");
	printf("\n\n\t The differential function: 3x^2 - 6");
	printf("\n\n\t x0 value \t\t x1 value ");
	do
    {
		x1= x0 - (f1(x0)/f2(x0));
		printf("\n\n\t %f \t\t %f",x0,x1);
		k = x0;
		x0 = x1;

	}
		while(k != x0);
	printf("\n\n\t\t root = %f\n", x1);
getch ();
}

Comments

Featured Blog Posts

Convert Currency in Number to Words (Indian Rupees) - MS Excel
Foxpro Tutorial and Programs
Convert Currency in Number to Words in MS Word
Convert Currency in Number to Words (Indian Rupees) - Version 2
Best way to Use Rupee Symbol in Windows – Easy steps
Convert Currency in Number to Words - MS Access
Creating All in One Windows XP DVD with all Important Applications
RSS feed

© 2009-2025 Live to Learn.In

Terms of Use | Privacy Policy