Wednesday, February 19, 2014

Hermite Interpolation.

My implementation is here:  https://github.com/BuckRogers1965/Examples/blob/master/Math/NumericAnalysis/04_Hermite.c

For the Hermite interpolation to work you need to not just measure the x and f(x) for your plot points, but also your f'(x).  So if you are measuring time and distance, you should also grab the speed at the same points.  Often this extra data is overlooked, which is a shame because it can often be collected at very little additional cost.

Then you double the points, and use the f'(x) at depth 1 when otherwise using the two points would result in division by zero.

This procedure only gives you the constant prefixes for each polynomial in the solution.  This starts with f(x) at the zeroth level, then the first value calculated at each level after that.  I push them all into a stack and then build the polynomial as I return from the recursive calculation of the results.

The depth you reach is stored in the depth of pushed values.  The degree of polynomial you generate is given by depth minus one.  The polynomial is calculated as shown by the printout.

No comments:

Post a Comment