# Linear Interpolation

Back in the old days, we used tabulated values to compute values of transcendental functions so that the results could be used in subsequent computations. We had tables for logarithms, trigonometric functions, and the like. There was no calculator or computer with which to enter a value and press log10 to estimate the logarithm of the number.

The method I was taught in high school (I think, it was a long time ago) is called linear interpolation. The assumption is that a straight line between entries in the table is a reasonable approximation for values in between.

That is not strictly true, because all of those functions are actually curves and deviate from a straight line between any two points on the function (according to the graph of the function). But, use of interpolation is certainly sufficient for scientific and engineering calculations.

Therefore, I learned to use linear interpolation to estimate the in-between values. The process is simple, computationally. The bounding values from the table are used to estimate a slope of the line between the two values. That slope multiplied by the fraction of the distance between the interval endpoints of the desired value of the independent variable is added to the initial interval endpoint of the dependent variable. The result is the estimate of the dependent variable on the bounding interval.

Probably 20-years ago I was working on a spreadsheet to route a runoff hydrograph through a reservoir. The algorithm is called modified Puls and is an expression of the conservation of mass principle of the hydrograph through the reservoir with the assumption that the slope on the reservoir surface is zero (it’s flat). The process involves generation of several tables of values and then using those tables to execute the algorithm. Most of the time the desired values from the algorithm fall between tabulated values. Therefore, interpolation is required.

The brute force technique would be to hand code each cell of the spreadsheet to advance the calculation. I wanted a more general (and perhaps elegant) solution so that I would not have to hand code each cell. I thought it should be possible to write a general formula using the built-in search function of the spreadsheet over the range of values in the table.

I recall working on this for a couple of days. I was a professor, so I could afford to spend the time on the problem. I constructed a solution using a function in Microsoft Excel called VLOOKUP. I am not going into the details here (I have a white paper here), but it is sufficient to say that I did the work, solved the problem, and forgot about it.

I also forgot where I put my notes on how I constructed the solution. As it turns out, I needed (or rather wanted) to use this approach to solve an engineering problem I’m working on. I couldn’t find my notes. A couple of weeks ago I hand-coded the cells just so I could get a solution. But last it became apparent that I might have to make several solutions of the problem using the same tables.

I needed to regenerate the general solution, once again. I did this a couple of days ago. Then, yesterday morning, I woke early and was unable to go back to sleep. So, I rose, made coffee, and wrote my notes so that I would have a reference should I need to use the solution again. (Hence the production of the white paper above.)

I am reminded that there are many times we work out a problem, or we learn something that challenges us in some manner. But then, with the immediate problem solved, we move on and never take time to note what the problem was, what the constraints were, what the solution was, and what we learned. We are carried away by the pressing current of other tasks, other duties, or just the ebb and flow of life.

Then, weeks, months, years, or decades later, we find ourselves facing a similar problem that, hopefully, would have a similar solution. In a frantic whirlwind of energy, we search for the solution we know we found but cannot recollect. We know we solved the problem. We remember working on it, struggling intellectually or emotionally, and the expenditure of intense energy grinding toward the solution. Then, solution found and the immediate need passed, we remember having moved on without taking the time to reflect. We curse our impatience, or failure to document what we learned, and our stupidity.

But we know, having solved the problem once before, we can find the solution (or an equivalent solution) again. So we pick up the trail, work out the solution, and solve the problem once again.

Then what? The wise will set the brake, pause, and make note of the problem, the constraints, and the derived solution. I know that I learned my lesson on this one. Will I make the same error again? Probably. But I won’t make this same error again. I have my notes. I know how to solve this problem.

What about you? What is the problem you’re faced with? Is it one you solved before? Did you pause to make notes after developing the solution? Will you make the same mistake that I did?

## 3 thoughts on “Linear Interpolation”

1. Because, by now, my memory is very far from being reliable, if I were to make notes, I would have just about no time for anything else. Fortunately, the “processor” is still working so I just keep reinventing the wheel. But you are right of course.

1. ruminator says:

I have to have notes. Sometimes a long period of time passes between uses of something I learn. Without the notes, I have to relearn what learned and that might take a lot of energy.

1. As I said, you are right of course. (The key word was “By now,”)