cancel
Showing results for 
Search instead for 
Did you mean: 

work out poly

cjaya.2
Associate II

Need a help to work out the formula. I cant get my head around with this to work out. its polynomial with numerator and denominator. what is the formula for this. Thank you

 

FLOAT_TYPE num_coeff[] = {-2.42580348918581e2l, 4.43575581447635e2l, -8.6570608699616e2l, 7.34933695653457e2l, -7.02396810482965e1l};

FLOAT_TYPE den_coeff[] = {1.e0l, -8.87493143817912e-1l, 2.75291524634514e0l, -3.88521936154463e-1l, 9.08722079164108e-3l};

FLOAT_TYPE num_poly = num_coeff[sizeof(num_coeff) / sizeof(num_coeff[0]) - 1];

FLOAT_TYPE den_poly = den_coeff[sizeof(den_coeff) / sizeof(den_coeff[0]) - 1];

for (int i = (sizeof(num_coeff) / sizeof(num_coeff[0]) - 2); i >= 0; --i)

   {

   num_poly = num_poly * r + num_coeff[i];

for (int i = (sizeof(den_coeff) / sizeof(den_coeff[0]) - 2); i >= 0; --i)

  {

  den_poly = den_poly * r + den_coeff[i]; } return (num_poly / den_poly);

  }

5 REPLIES 5
TDK
Guru

num_poly(x) and den_poly(x) are each polynomials.

Result gives you num_poly(x) / den_poly(x).

Here, num_poly(x) = -2.42580348918581e2 + 4.43575581447635e2 * x - 8.6570608699616e2l * x^2 + 7.34933695653457e2 * x^3 - 7.02396810482965e1 * x^4

And den_poly(x) = 1.e0 - 8.87493143817912e-1 * x + 2.75291524634514e0 * x^2 - 3.88521936154463e-1 * x^3 + 9.08722079164108e-3l * x^4

 

If you feel a post has answered your question, please click "Accept as Solution".

Thank you for the reply and formula. When I did the excel calculation on this I get a different answer using the above formula. But When I complie it I get different answer. Why is that

These are the numbers for derived formula.

1.000
1.038
1.057
1.067
1.077
1.081
1.085
1.089
1.092
1.096
1.100
1.104
1.108
1.112
1.116
1.193
1.289
1.385

float res2temp(float r)

{

  int ni;

FLOAT_TYPE num_poly = num_coeff[sizeof(num_coeff) / sizeof(num_coeff[0]) - 1]; FLOAT_TYPE den_poly = den_coeff[sizeof(den_coeff) / sizeof(den_coeff[0]) - 1];

for (ni = (sizeof(num_coeff) / sizeof(num_coeff[0]) - 2); ni >= 0; --ni)

{

num_poly = num_poly * r + num_coeff[ni];

}

for (int i = (sizeof(den_coeff) / sizeof(den_coeff[0]) - 2); i >= 0; --i)

{

den_poly = den_poly * r + den_coeff[i];

}

return (num_poly / den_poly);

}

 

In this function I pass res2temp(6.e4f * adc_result / (1074547130368ll - (3ll * adc_result)))

The adc_result I putting are,

17909418.84,
18598931.46,
18944583.25,
19116513.67,
19288444.09,

19358290.82,

19426346.62,

19496193.35
,19564249.14
,19634095.87
,19702151.67
,19771998.4
,19840054.19
,19909900.92
,19977956.72
,21356981.97
,23081659
,24804545.09

its the same numbers when calculated adc_result, I mentioned above entering into excel but why excel gives different answer?

 

 

Is it not like this , because I am not getting write answer

Num Poly = -70.2397+ 734.9337x-865.7061x^2 + 443.5756x^3 - 242.58x^4

Den Poly = 0.009087 - 0.38852x + 2.752915x^2-0.88749x^3 + x^4


@cjaya.2 wrote:

Is it not like this , because I am not getting write answer

Num Poly = -70.2397+ 734.9337x-865.7061x^2 + 443.5756x^3 - 242.58x^4

Den Poly = 0.009087 - 0.38852x + 2.752915x^2-0.88749x^3 + x^4


I edited my response. Perhaps you are looking at the un-edited version. Here is what I wrote:

 

Here, num_poly(x) = -2.42580348918581e2 + 4.43575581447635e2 * x - 8.6570608699616e2l * x^2 + 7.34933695653457e2 * x^3 - 7.02396810482965e1 * x^4

And den_poly(x) = 1.e0 - 8.87493143817912e-1 * x + 2.75291524634514e0 * x^2 - 3.88521936154463e-1 * x^3 + 9.08722079164108e-3l * x^4

 

If you feel a post has answered your question, please click "Accept as Solution".