%% Cubic interpolation translated to HP by L.R.Linares %% from a C program by Paul Burke, 2007. %% This program is provided 'as is' and no guarantee is %% made in as much as its accuracy or correctness. %% %% You need two points of the curve to the left your your %% 'quest' and two points to the right of your 'quest'. %% x0 x1 x2 x3 are assumed to be equally spaced, so only %% the two x1 and x2 (the closest to the quest) are %% necessary. %% The program returns the same group of numbers it %% received (see the prompt at the top of the program below) %% but replaces 'x' by the corresponding 'y' value. << "y0 y1 y2 y3 x1 x2 x" PROMPT -> y0 y1 y2 y3 x1 x2 x << '(x-x1)/(x2-x1)' EVAL 'y3-y2-y0+y1' EVAL DUP 'y0-y1' EVAL SWAP - 'y2-y0' EVAL y1 -> mu a0 a1 a2 a3 << '(((a0*mu+a1)*mu+a2)*mu+a3)' EVAL y0 y1 y2 y3 x1 x2 6 ROLL >> >> >>