Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Borland C++ 2.x ( with Turbo C ) - <b>poly() generate a polynomial from arguments</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 poly()                  Generate a Polynomial from Arguments

 #include   <math.h>

 double     poly(x,num,cf);
 double     x;
 int        num;
 double     cf[];

    poly() generates a polynomial in 'x', of degree 'num', with
    coefficients cf[0], cf[1],...,cf[num].  For example, if 'num' = 4,
    the generated polynomial is

             cf[4]x4 + cf[3]x3 + cf[2]x2 + cf[1]x + cf[0]

       Returns:     The value of the polynomial as evaluated for 'x'.

   -------------------------------- Example ---------------------------------

    The following statements evaluate the polynomial for five values of x
    and print the results.

           #include <math.h>

           main()
           {
               double x, y;
               int num = 4;
               double cf[5];
               int q;

               for (q = 1; q < 6; q++) {
                   x =  q + .5;
                   cf[0] = 56;
                   cf[1] = -106;
                   cf[2] = 63;
                   cf[3] = -14;
                   cf[4] = 1;
                   y = poly(x,num,cf);
                   printf("when x = %.1f, y = %.4f\n",x,y);
                   }
               }



Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson