I use the library <Math> . You need to specify a formula by which each term will be consistent ( -3-4x-5x^2... ).

 for(d=-3;n=1;n++) { d=d*xx^n } 

How to set x ^ n?

    2 answers 2

    Exponentiation:

     #include <cmath> double res = pow (x, n); 

    By the way, which platform and compiler?

    And another thing: if you build to an integer degree (especially a small one), then it’s faster just to multiply the numbers.

      In your case, the poly (...) function from math.h is useful.

      Well, dear @mikillskegg , without poly ():

       double Polynom(const double x, const int n) { double R = 3.0, powX = 1.0; for(int i = 1; i <= n; i++) { powX *= x; R += (i + 3) * powX; } return -R; } 
      • one
        But it seems to be a non-standard function, in Linux, for example, it does not. - skegg
      • @mikillskegg. What is the "standard" function, dear colleague? - BuilderC
      • 3
        Well, this is a type of function, the presence of which in the library is mandatory according to the standard. Something like that ... - skegg