LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

polynomial evaluation vi giving inconsistent results

Solved!
Go to solution

I was looking at an easier method to do a polynomial evaluation, rather than using the formula nodes that i currently use.  I found the "Polynomial Evaluation vi" which one would think based on the help would be able to calculate the result of a multi exponent polynomial.  

Currently i would do something like the following in a formula node:

 

float64 D1=0.387481063640E-01;
float64 D2=0.332922278800E-04;
float64 D3=0.206182434040E-06;
float64 D4=-0.218822568460E-08;
float64 D5=0.109968809280E-10;
float64 D6=-0.308157587720E-13;
float64 D7=0.454791352900E-16;
float64 D8=-0.275129016730E-19;


DC= (V*D1)+(D2*V**2)+(D3*V**3)+(D4*V**4)+(D5*V**5)+(D6*V**6)+(D7*V**7)+(D8*V**8);

 

I tried the same calculation by writing a small VI that used the polymomial evaluation vi and get seriously incorrect results.  (my vi attached.)

Looking into the polynomial evaluation vi, i dont honestly know how it's supposed to work, unless it's trying to do somethign completly different than i'm doing.   (Using labview 2015)

 

I'm open to any suggestions here.  Thanks!  Mitch

 

 

 

0 Kudos
Message 1 of 3
(3,354 Views)
Solution
Accepted by topic author Mitch_cottrell

The first term of the array is the constant term (V^0=1), so you need to prepend an element that is zero to the array of coefficients.

 

The polynomial is defined as:

DC = D0 + (V*D1)+(D2*V**2)+(D3*V**3)+(D4*V**4)+(D5*V**5)+(D6*V**6)+(D7*V**7)+(D8*V**8)

In your case, D0=0, but it still needs to be there.

 

 

 

 ... and don't make the diagram constant EXT. As you can see from the coercion dot, it will be converted to DBL anyway.

0 Kudos
Message 2 of 3
(3,344 Views)

what X values do you use with your polynomial?

Is double precision enough, what precision do you actually need?

With x = 1 difference between your first order and last order is 18 digits - you are 1000 times below double precision, last one is lost. Only D7 makes a little bit of sense.

With x = 10 difference is 10 digits and last one is valid

If you need higher precision, I would save a copy of polynomial evaluation, remove internal "Remove Zero Coefficients.vi" and change representation of controls to extended.

 

Polynomial evaluation is fine: it loops coeffs from the highest order (reverse 1D array in beginning). For example for the 3-d order it is like:

(((0+a3)*x+a2)*x+a1)*x+a0

It reduces total number of multiplications.

0 Kudos
Message 3 of 3
(3,316 Views)