Tuesday, January 27, 2009

C: Cubic Splines Interpolation

I started working at Olin Rocket Research as an applications programmer soon after I graduated from the University of Washington.  I was hired to maintain existing engineering applications that were written in Basic, Fortran, or Lotus macros for the Chemical and Reliability Engineering departments.
Among the projects I was assigned was to perform data reduction on about seventeen years of test laboratory data that tracked, over time and temperature change, the reaction with hydrazine rocket fuel of different metals that might be used in rocket fuel tanks, plumbing, or nozzles.  The product of the work was to be two-dimensional line charts that showed the measure of the reaction recorded -- the amount of gas generated.
The problem with the tool available at the time, Lotus, was it rendered line charts in jagged, sawtooth patterns. The extremes of those charts reflect measured, accurate values, but nearly all of the points in between were not accurate. The slope of the curve approaching and leaving a naturally occurring measured data point is almost never sharply steep, flat, and then sharply steep in the other direction in the span of three infinitesimally small data points. Instead, the slope approaches and leaves zero comparably slowly at each maximum or minimum point, and curves gradually as it connects them.
To improve the quality of the visual rendering I wrote a new program that generated a large number of additional data points using cubic splines interpolation on the lab-measured data points. That involved predictive calculation of a more natural first and second derivative on both sides of each inflection point based on the slope of the surrounding lines' midpoints.  With the new data points the chart would be redrawn using many more data points than those actually measured, which would effectively correct the sawtooth pattern with curves, much like the effect of using a french curve drafting tool.  Each line reflected what near instantaneous measurement would've shown.

No comments:

Post a Comment