[6.31] Fast 2nd-order interpolation with QuadReg
Linear interpolation is adequate for most table-interpolation problems. A second-order (quadratic)
interpolation is more accurate, but it does require entering one more data point. The first-order (linear)
interpolation uses two points to find the coefficients a and b in
ax
+
b
=
y
then calculates y at your desired x. A second-order interpolation uses three points to find a, b and c in
ax2
+
bx
+
c
=
y
and again finds y at your desired x. The coefficients can be found as those of a Lagrangian
interpolating polynomial, but that is not built-in to the 89/92+. Quadratic regression is built-in, and it can
be used to find the coefficients. The basic steps are
1. Save the x- and y-coordinates for the three points to two list variables, one for the
x-coordinates, and one for the y-coordinates.
2. Execute the QuadReg command with the two lists.
3. Use the built-in system function RegEq(x) to interpolate y = f(x)
As an example, suppose that we have a table of gamma function values for x=1 to x=2, spaced every
0.04. We want to find gamma(1.895). We choose the three table x-values which bracket our desired
x-value of 1.895, where the middle x-value is the one closest to the desired x-value. From the table, the
three points are
x1 = 1.84
y1 = 0.94261236
x2 = 1.88
y2 = 0.95507085
x2=1.88 is closest to x=1.895
x3 = 1.92
y3 = 0.96877431
Then these steps estimate gamma(1.895):
{
1
.84,
1
.88,
1
.92}
→
lx
{.9426
1
236,.95507085,.9687743
1
}
→
ly
QuadReg lx,ly
regeq(
1
.895)
which returns gamma(1.895) = 0.96006375. The actual answer is 0.960062793, for an error of about
9.6E-7. Linear interpolation results in an error of about 1.5E-4, so the 2nd-order interpolation gives
several more significant digits.
Note that the regeq() function is a system variable that is updated when any regression command,
including QuadReg, is executed. Once you have executed QuadReg, you can use regeq() to
interpolate for additional x-values, as needed. These values need to be between x1 and x2, or you are
not interpolating, you are extrapolating, which is much less accurate.
This method cannot be written as a function because the QuadReg command only accepts global list
variable names as arguments. The QuadReg arguments must be list names, and not the lists
themselves.
I built this method into a program called QuadInt(), which is shown here:
quadint()
6 - 57
Summary of Contents for TI-92+
Page 52: ...Component side of PCB GraphLink I O connector detail 1 41...
Page 53: ...LCD connector detail PCB switch side 1 42...
Page 54: ...Key pad sheet contact side Key pad sheet key side 1 43...
Page 55: ...Key cap detail 1 44...
Page 57: ...Component side of PCB with shield removed A detail view of the intergrated circuits 1 46...
Page 410: ...void extensionroutine2 void Credit to Bhuvanesh Bhatt 10 4...