# How to make a formula that will interpolate a curved line graph?

In this curved line graph, I need to be able to make a formula that can tell me the interpolated value at any point on the curved path given one Data input.

So for example if I wanted to know what value the line was at exactly half way between Point 2 and Point 3, I can eyeball it and tell it would be somewhere around 3.0 for a value, and to get it more exact I could use a ruler and some math. But that is the long way of finding 1 point on the curve at a time. Is there a generic formula that can take any arbitrary curved path with a set of points (a curved path that has no real pattern except that it's a collection of splines with known points to interpolate between) and turn it into a mathematical formula that you could input a Data 1 and it spits out the Data 2 value of the curve where the Data points meet, or vice versa?

For example,
Input Data 1 to math formula = Point 2.5
Data 2 = [Computed by math formula] 3.0

or

Input Data 2 to math formula = 3.0
Data 1 = [Computed by math formula] Point 2.5

Just need the method to develop the math formula!

-

I have realized this is impossible for my scenario. The actual application of this would be for a graph with hundreds of points, all using splines, not Lagrange polynomial curves, which curve the line differently than splines somewhat, throwing off the accuracy which is all-important. Even using spline interpolation in Mathematica with dozens of points wasn't accurate enough. The only way to do this that I have found is by using AutoCAD (or some other exact distance measurement) on the graph to interpolate as exactly as possible (to about 3 decimal places).

A formula would be rather impractical, however, a way to take a curved line/set of curved lines in AutoCAD and create 100,000 points on it evenly spaced could be possible in the future. You could then export the 100,000 points to something like Microsoft Access database as a table, then create a query that would find the nearest point out of the 100,000 points to whatever Data 1 or Data 2 you input, but I don't have a clue how to do this in practice.

-
Maybe I misunderstood. I thought you just wanted an equation for a curve passing through the given data points (four of them, in this case). Now it sounds like you want the equation to match the shape of the graph in your picture, not just match the four points. That can be done. Take a large sample of points from the graph, and fit a spline through them. To get answers accurate to about 3 decimal places, I'd guess that a few dozen points is enough. The technique you described (storing 100,000 values) is just a very crude form of approximation/interpolation. Better to use a spline. – bubba Jan 19 '13 at 8:05
Obviously the answers given have not been successful. I'm pretty sure that there is nothing special about AutoCAD in this area. Anything that you can do in AutoCAD, you can do using the techniques described in my answer and comment. Curve fitting obviously is possible -- people do it every day, and they do it without using vast tables of points. – bubba Oct 25 '13 at 0:43

If you just have four data points (or some smallish number, anyway), then the easiest approach is probably something called "Lagrange interpolation".

The wikipedia page has a bunch of formulas that might be hard to understand, but the examples should be pretty clear:

For four given data points, you will get a cubic (degree three) equation of the form $y = ax^3 + bx^2 + cx + d$, which you can then use to get intermediate values anywhere.

-