09-30-2016 01:36 PM
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
Solved! Go to Solution.
09-30-2016 02:00 PM - edited 09-30-2016 02:09 PM
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.
09-30-2016 03:13 PM - edited 09-30-2016 03:15 PM
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.