Reading through your comments and revisions to the question, there are a couple of things you want to do that aren't really covered in my previous answer. This answer will deal with those items, and I've included a step-by-step walk-through of how you would accomplish the whole interpolation process.
Inaccurate Data
You describe the process that generated the data as taking readings at a time interval, and the numbers are rounded times. The equation is only as good as the data. In your actual analysis, you should use the most precise numbers available (perhaps you were just keeping your example simple by showing rounded times).
However, the data you show don't precisely fit the kind of curve you typically see for a physical process. Theoretical curves are generally smooth when there is just one driving variable and no noise. If you are using very precise equipment both to trigger a reading at a preset interval and to provide an accurate measurement, you can accept the results as precise. However, if you are manually timing the reading and manually taking the reading, the X
values can be at imprecise times even if the readings, themselves, are accurate. Shifting individual X
values a little one way or the other will introduce the kinds of small irregularities you see in the curve of your data (unless the example is just numbers you made up for the purposes of an example).
If this is the case, you might benefit from using regression to estimate best fit.
Using Y as X
In your problem, you want to define values for Y
(integer values from 1 to 37 in this example), and find the associated X values. That was easy enough to do in your Y=2^X
problem because that simple equation can easy be reversed to X=log(Y)/log(2)
, and you can directly calculate any value you want. If the equation isn't something simple, there often isn't a practical way to invert it. The "abused" regression approach in my previous answer gives you a high order equation, but it's "one-direction", often not practical to solve for the reverse equation.
The simplest approach is just to reverse X
and Y
from the start. This gives you an equation you can use with the integer values you introduce (the analysis gives you the coeficients of the equation as described in the previous answer).
It never hurts to see if a simple curve will work. Here's the reversed data, and you can see that there's not a useful fit:
![log](../../I/static/images/2f21399aac6c4db3b948022b10ea62793f64086a0be040d9f071d221992ceb21.png)
So, try a polynomial fit. However, this is a case like I described in the previous answer. The values from 1 through 8 fit well, but 9 gives it indigestion. A 3rd order polynomial gives you a bump:
![poly3](../../I/static/images/bc90d37426c27ff35f941dfe6626c9e4c8c9ab15b26b8e67294b576e1828768c.png)
It gets progressively more "interesting" as the order of the equation increases. By the 7th order, you get this:
![poly7](../../I/static/images/a79a55156e8b417d9d78d687be334b4e05397584e4238c07759d83d95f5cbbb8.png)
It goes almost exactly through every point, but the curve between 8 and 9 isn't useful. One solution would be to make do with linear interpolation between 8 and 9. In this case, though, you could get better values by incorporating splines for the upper end. The splines option provides a good looking fit, and a curve that makes more sense between 8 and 9:
![splines](../../I/static/images/a31af57c6b7670e0b1c8805e16d7453b4b0806f71059984a522c56e60f7a48f1.png)
Unfortunately, the spline equations are a bit convoluted and the equations are not provided. However, you could do the linear interpolation on the intermediate values provided by the analysis, which should get you very close to numbers that fit a reasonable curve.
Extrapolation vs. Interpolation
In this example, your first Y
value is 2.9. You want to produce values for 1
and 2
, which are outside the range of the data. That requires extrapolation rather than interpolation, which is a very different requirement.
If the equation is known, like your Y=2^X
example, you can calculate any value you want.
If the process generating the data is known to follow a simple curve, and you are confident of the fit, you can project values outside the data range, and even get a meaningful confidence interval for the range that the values could actually be (based on how much variation there is between the data and the curve inside the data's range).
If you're force-fitting a high-order equation to the data, projections outside the data's range are usually meaningless.
If you are using splines, there is no basis for projecting outside the data range.
Whatever projections you make outside the range of your data are only as good as the equation you use, and if you're not using an exact equation, the farther you get from your data, the more inaccurate it will be.
Looking at the log curve in the first graph, you can see that it would project a very different value than what you would expect.
For the polynomial equations, the zero-power coeficient is a constant, and that's the value that would be produced for an X
value of 0
. So that's a simple way to look at where the curve would go in that direction.
![zero vals](../../I/static/images/e8873f9ead1d16adc1e787ee3e8425de952ecf4a560ec54651b1aa03bc90420f.png)
Note that by the 4th or 5th order, the points 1 through 8 are pretty accurate. But once you go outside the range, the equations can behave very differently.
Extrapolation using limited data
One way to improve things is to fit only the points at that end, and include as many successive points as follow the shape of the curve at that end. Point 9 is obviously out. There are several inflections in the curve before that, one being around point 5 or 6, so points higher than that follow a different curve. Using just the points 1 through 5, you get close to a perfect fit with a 3rd order polynomial. That equation would project a zero point of 0.12095 (compare to the table above), and for an X
value of 1
, 0.3493
.
What happens if you just fit a straight line to the first five points:
![straight](../../I/static/images/c484969e1972bf5d0791d00042da1bf8952d0d184975f6cf9eeca8b30ca1e7cc.png)
That projects a zero point of -0.5138 and for an X
of 1
, -0.0071
.
That range of possible outcomes indicates the level of uncertainty outside the range of your data. There is no right answer. And this was at the "well-behaved" end of your curve. The Y
value for an X
of 9
is 36.7
. You want to go to 37. The splines suggest that the curve is asymptotic at 9
. Projecting a straight line in the raw data would produce a value a little more than 9
(same with a 4th order polynomial). A 3rd order polynomial suggests a value less than 9
(as do 5th and 6th orders). A 7th order polynomial suggests a value substantially above 9
. So anything outside of the data range is a guess, or anything you want it to be.
Putting it all together
So let's step through what the actual solution would look like. We'll assume you've already tried to find an exact equation and tested common curves using a trend line. The next step would be to try regression because that gives you the formula for the curve and you can plug in your integer values.
I don't have ready access to Excel 2013 or the Analysis Toolkit. I'll use LibreOffice Calc to illustrate this. It's not identical, but it's close enough that you should be able to follow it in Excel. In LO Calc, this is actually a free extension that needs to be loaded. I'm using CorelPolyGUI, which can be downloaded here. My recollection of the Analysis Toolkit is that it didn't include splines. If that's still the case and you want to do this in Excel, I came across this free add-in (which I have not tested). An alternative would be to use LO Calc, which will run in Windows and is free.
![step 1](../../I/static/images/d62f85fae10239997b23a2b08dbed21ca8aa2718738f8f51477ce6a4bea2dd19.png)
Here, I've entered the X and Y values (reversed) in columns A and B, and opened the analysis dialog. Highlighting the X values and clicking the X button loads the data ranges, and I've selected polynomial.
![step 2](../../I/static/images/a0cf744f0802f509b63df8ffe9eef6c461d56def4d4945912afb313ae82cdbbc.png)
On the next tab, I specify that I want to use 0
to 7
degrees (a 7th order polynomial with all of the orders).
![step 3](../../I/static/images/1ad26222e176d35e10b9b12f57670b0f3f1cdf1d0db16b0c77311f8498d5200b.png)
To specify the output, I select C1 and click Columns, and it registers the columns needed for the output. I select that I want it to output the original data, the calculated results, and I've selected to have it add three intermediate points between each original data point. And I tell it I want a graph of the results on a new chart. Then go to the calculate menu and click calculate.
![step 4](../../I/static/images/c7f00e2dbdce1d41e473633c51010c5c7ddbc3f598d34703ffd10c6c6bc16f12.png)
And there it is. If you look at the calculated values, you may notice a problem. It will become apparent in the next step.
![step 5](../../I/static/images/f6e5b0d9e37c515defa17d1ba6f76712a295dbc2c25e0ed9348a283ab7be5bae.png)
Here, I've added the 1
through 37
values. At this point, we only want to deal with interpolation, so I've added a formula to calculate only the values 3
through 36
. The formula just expands the coeficients listed in the results (the a(n) values). The formula in I2 is:
=D$4+D$5*H3+D$6*H3^2+D$7*H3^3+D$8*H3^4+D$9*H3^5+D$10*H3^6+D$11*H3^7
This is just each coeficient multiplied by the associated power of the X value. Drag this down and you have your results. Well not quite; you have to look at it to see if it passes the sanity test. We knew there was a problem between 8
and 9
, but that turns out to be half of the values you want. We could use the values from 3
through 20
, but there's no sense in combining that many values from another method. So let's just use splines for the whole thing.
![step 6](../../I/static/images/d9f14871ec6dc7162381ca1c51a6c10a6621799511bc8f8e8d9367de780a1b7e.png)
Open the analysis dialog again, and change the method to "splines" on the input tab (not shown here). Give it a new output range and tell it to calculate. That's all it takes.
![step 7](../../I/static/images/602d8e836fa83eabbf8a0e18930b864c2612e968d40a10e7cc6b41b2c9adb93a.png)
We have new results to work with. Dividing the data range into this many segments keeps each segment short, so linear interpolation should be pretty good (way better than using it on the original data).
![step 8](../../I/static/images/e3c9797fa8993fdb4d74a3de4980630d9d6fff7f98d277ab70cc45e547d82b12.png)
The process of curve fitting or interpolation involves creating data points; using your own judgement about what the curve "should" (or should not), look like (regression assumes that even the original data are imprecise).
Giving this data a sanity check shows that even splines produce a connecting curve with a bulge; one value goes slightly over 9
, which is likely an artifact rather than a reflection of the process you were measuring. In this case, a curve asymptotic at 9
is more likely, so I arbitrarily assigned the high point a value that's a hair less than 9
by eyeballing it. The assumption isn't that my value is precise, only that it's an improvement. For this illustration, I created a new column with the values that will be used.
I added a column with your numbers 1
through 37
. From the previous discussion, we don't have a reliable basis for projecting values for 1
and 2
, so I left them blank. For 37
, I went with the asymptotic assumption and made it 9
. The values for 3
through 36
are found by linear interpolation (and it's a formula you could adapt to other data). The formula in Q3 is:
=TREND(OFFSET($M$1,MATCH(P3,M$1:M$33)-1,2,2),OFFSET($M$1,MATCH(P3,M$1:M$33)-1,0,2),P3)
The TREND function just interpolates when the range is two points. The syntax is:
TREND(Y_range, X_range, X_value)
The OFFSET function is used for each range. In each case, it uses the MATCH function to find the first row of the range containing the target value. The -1
values are because these are offsets rather than locations; a match in the first row is an offset of 0
from the reference row. And note that the Y
column is offset by 2
, in this case, because I added an extra column to manually adjust a value. The OFFSET parameters pick the column containing the Y or X values, and select a range height of 2, which gives you the values below and above the target.
The result:
![result](../../I/static/images/1b0d1b1215a6e99567f796f3a0eb2f7e23b39f7894a589c9493ac7f4100dfe5b.png)
The analysis wizard does the heavy lifting, and whether you're using polynomial regression or splines, it required just one formula to generate the result.
2This is a duplicate of your subsequent question. In order to interpolate, you need to decide on the relationship between the values. In your this question, a 4th-order polynomial fit (or over-fit) the data; in your subsequent question, there is an exponential relationship between the values. Once YOU decide on the relationship, then it's a matter of applying the appropriate formula. For this set of data, you would insert a column of equally spaced values in rows 1..36 that go from 1..9, and then use a variation of the
TREND
function to calculate the Y values – Ron Rosenfeld – 2015-10-11T20:04:20.220For both of your questions the desired activity is REGRESSION, please change the wording of your questions. There is no universal built in solution for that, but you may find useful as-ins on the web using the right keywords – Máté Juhász – 2015-10-12T06:35:03.450
1@MátéJuhász: Without X values, it also isn't regression. :-) But regression is actually a little different from the requirements here. Regression is an approximation based on all of the data, which may not actually pass through any data point. What the OP wants here is interpolation between the actual points. He doesn't specify the nature of it, so linear interpolation would meet the requirement, but Gary's Student's answer on the other question uses the actual exponential curve. – fixer1234 – 2015-10-12T07:48:59.360
Gentleman, I was unfortunate to produce the second question, when choosing a 2^n exponential data. Most of the answers were sit over the 2^n focus. It should not. This is why I am returning here, with the original data: Nine elements, X=1 to 9, Y=2.9, 5.06, 7, 8.84, 10.87, 13.24, 16.22, 20.25, 36. As the highest Y element is 36, I would like to expand X to 36 elements and obviously X1=1, X12=7, X36=36, but I need to fill up the blanks in Y relative to X. – Wagner Lip – 2015-10-13T19:09:49.573
I have three problems, first; my native language is not English, second; I have no strong math background, and third; it seems there is no solution for my Excel table exercise. I am not abandoning the questions, I am just following recommendation to edit the first post. In addition, it is possible I am failing completely in using this forum. Thanks. – Wagner Lip – 2015-10-16T04:42:52.713
Okay, I was able to find a time consuming formula. 1) I created a column (K) containing the difference between the B column elements. K5 = B5-B4. That is the Y displacement for every X element. 2) Column E will contain as many sequential integer numbers (37), starting by 1, as the next integer value of the biggest element in B, in this case, the B9 contents (36.7). On F1:F37 I input the following formula (next comment): – Wagner Lip – 2015-10-17T00:05:36.647
=IF(E1>$B$9,$A$9+(E1-$B$9)/$K$9,IF(E1>$B$8,$A$8+(E1-$B$8)/$K$9,IF(E1>$B$7,$A$7+(E1-$B$7)/$K$8,IF(E1>$B$6,$A$6+(E1-$B$6)/$K$7,IF(E1>$B$5,$A$5+(E1-$B$5)/$K$6,IF(E1>$B$4,$A$4+(E1-$B$4)/$K$5,IF(E1>$B$3,$A$3+(E1-$B$3)/$K$4,IF(E1>$B$2,$A$2+(E1-$B$2)/$K$3,IF(E1>$B$1,$A$1+(E1-$B$1)/$K$2,E1/$K$1))))))))) – Wagner Lip – 2015-10-17T00:10:09.797
I may be wrong, but for me this is interpolation. It works pretty fine. But it is not an automated formula, one must enter as many "IFs" as elements in the columns A+B (X+Y). I hope Excel has some of those ready made index or lookup by matrix that could be used. The formula above is from the cell F1. Any help is appreciated. Wagner – Wagner Lip – 2015-10-17T00:13:00.697
X:Y scatter with lines from A1:B9 or Inverted X//Y from E1:F37 generated exactly the same cure shape, so it works. But it is not the solution. – Wagner Lip – 2015-10-17T00:15:53.557