c program to implement newton raphson method for finding roots of a polynomial

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sekitoleko
    New Member
    • Sep 2006
    • 21

    c program to implement newton raphson method for finding roots of a polynomial

    c program for newton raphson algorithm for finding roots of a polynomial
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    Originally posted by sekitoleko
    c program for newton raphson algorithm for finding roots of a polynomial
    Why won't you try to write it yourself and then post at a more specific problem?

    Comment

    • sekitoleko
      New Member
      • Sep 2006
      • 21

      #3
      c program for newton raphson using a for loop

      how can i implement a c progran for newton raphson algorithm using a for loop?

      Comment

      • Banfa
        Recognized Expert Expert
        • Feb 2006
        • 9067

        #4
        Originally posted by sekitoleko
        how can i implement a c progran for newton raphson algorithm using a for loop?
        Please dont double post.

        Please do have an attempt yourself first.



        Do you know how the newton raphson method works?

        Comment

        • sekitoleko
          New Member
          • Sep 2006
          • 21

          #5
          c program for newton raphson method

          #include<stdio. h>
          /Calculate j(10) from j(0)
          int main()
          {
          int n;
          double j=0.6;
          printf("forward iterations\n");
          printf("initial estimate:j(0)=% g\n",j);
          for(n=1,n<=10,n ++)
          j=1-(j*n);
          printf("j(%d)=% g\n",n,j);
          }
          return 0;
          }
          this code is not helping me find roots of( x*x-2).What do I need to change?

          Comment

          • iknc4miles
            New Member
            • Oct 2006
            • 32

            #6
            Ok, let me see if I understand your code.

            I'm a numerical methods and modeling engineer so I should understand the Newton-Raphson Method to be:

            j( i+1 ) = j( i ) - [ j( i )^2 - 2 ] / [ 2*j( i ) ] for the function f( j ) = (j*j - 2).

            So, you should step i forward until f( j ) is within your tolerance of 0. Then your answer should be your last j.

            Here's some pseudocode:

            i = 0

            while( absoluteValue( f( j ) ) > toleranceValue)
            {
            j = j - [ f( j ) ] / [ df( j ) ];
            i++;
            }
            printOut("Root of Function is at %g After %d Iterations" j, i );

            When you write this out in whatever language you want, should work.

            - Miles

            Comment

            • Banfa
              Recognized Expert Expert
              • Feb 2006
              • 9067

              #7
              Please DON'T double post (hmmm I seem to be repeating myself here)

              Read This

              Comment

              Working...