LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

fourth order central derivative method misbehaving

Fourth Order Central method for computing a derivative appears to misbehave.

I am talking about Derivative x(t).vi, which is on palette "Mathematics", subpalette "Integ & Diff".

When computing derivative, user can specify the initial and final conditions for the routine to use when it gets to the "edges". The problem occurs if you leave either the InitialCondition or FinalCondition or both unwired. In that case, fourth order central returns zeroes for the entire dX/dt array.  Documentation says the VI assumes the initial/final values are zeros, if left unwired.  That should result in the first and/or last two values of dX/dt being erroneous, but the other values should be OK.

The attached routine shows all four ways of computing derivative, and allows the user to toggle the initial and final conditions between "Initial Value" and "Not Connected" and between "Final Value" and "Not Connected".  Notice what happens to the fourth order central derivative (labelled "4oc") when either toggle switch is "Not Connected": it is all zeros, contrary to expectation.  The other methods (Second Order Central, Forward, and Backward) behave as expected in all cases.

Do others get the same result?  If so, do you think my expectations are incorrect?

I think this is a bug in Derivative x(t).vi.  NI, is this the behavior you intended?

I am using LV 2013.  Thank you.

Bill R.

0 Kudos
Message 1 of 8
(3,502 Views)

I agree that this is a bug. If it behaved the same way for the other methods, it might just be a documentation issue.

 

The VI does generate error -20006:  The number of samples must be >= 2.  The default inputs to Initial Condition and Final Condition are 1D arrays of DBL with one element of 0. If they made the default arrays have two elements, everything would be OK. The other methods work the same with no array connected or with the two-element array. So a default 2-element array would allow the Fourth Order Central method to work with nothing connected and would not change the behavior of the other methods.

 

Wiring an array with 2 elements of NaN results in the first/last two elements of the derivative arrays also being NaN. NaN values do not plot, so this generates plots which have only valid derivatives shown. Depending on what you are doing with the derivatives, the NaN elements may cause other problems.

 

Lynn

Message 2 of 8
(3,472 Views)

Thank you Lynn.

Bill R.

0 Kudos
Message 3 of 8
(3,458 Views)

Hi Bill, 

I'll take a look into this issue and see if it is in fact a bug.  I'll keep you updated throughout the process.

Regards,
Kelly B.

National Instruments
0 Kudos
Message 4 of 8
(3,425 Views)

Thank you Kelly.

0 Kudos
Message 5 of 8
(3,419 Views)

Hi Bill, 

 

I've filed a report on this issue as CAR #517009.  Thank you for bringing this to our attention, and please post back if you have any further questions!

 

Regards,
Kelly B.

National Instruments
Message 6 of 8
(3,375 Views)

Thank you for keeping the thread updated. I posted this to the Monthly bugs thread.

 

Lynn

0 Kudos
Message 7 of 8
(3,364 Views)

Thanks Lynn!

Regards,
Kelly B.

National Instruments
0 Kudos
Message 8 of 8
(3,335 Views)