Updated algorithm with a function to calculate derivatives.

Algorithm should now be able to calculate both the first and second derivatives.

Refs #5591
Finishing up derivatives implementation.

Added correction for x points being out of order.

Refs #5591