Need Formula

Rail

New Member
Joined
Feb 3, 2004
Messages
25
Hello everyone!

I would like to figure out the formula for the given two columns of data.

The data:

X Axis = 0.5|0.75|1.0|1.5|2.5|3.5|4.5|7.5|15.0|25.0|35.0|45.0
(Numbers separated by vertical lines for ease of viewing)
Y Axis = (number's too large to list here...see below:)

1.509E-09 (this number corresponds to the 0.5 column)
1.111E-09 (this number corresponds to the 0.75 column)
8.536E-10 (ETC...)
5.001E-10
2.647E-10
1.788E-10
1.206E-10
5.231E-11
1.711E-11
1.248E-11
3.737E-11
6.706E-11

Should be a reverse exponential curve! I would like the formula to figure out the value that falls between the given numbers. Example: If I have a number (x axis) that falls between 7.5 & 15...say 10.1, I would like the formula to figure out the y-axis number...the number should fall between these to numbers: 5.231E-11 (which represents the 7.5) & 1.711E-11 (which represents the 15.0). I would like to set this formula up in Excel in a way that I could just type in a value and it will spit out the y-axis number.
I had a dos program that used to extrapolate these numbers but it's an old program and wont work on my computer.

I have about 15 sets of numbers that will have a different formula...so if you have time could you go over how to set up the data to get the formula. I want to thank you in advance for the effort on your part to help me out. Much appreciative!
 
Upvote 0

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
sixth sense, Thanks again for your reply!

your match works great if my value that I input is exactly the same as one of the original points on the graph...like the 0.5, 0.75, 1.0, 1.5 etc...

But if the value is not one of the original numbers the formula will have to interpolate it! I hope I can explain better..please forgive me...lets say we enter these numbers into the A column (our formula will be in the B column).

if you you should
input get
A B
1.5 5.001E-10
2.5 2.647E-10
but if you put in a number say between 1.5 & 2.5....for instance 2.2 the answer should give a value between 5.001E-10 and 2.647E-10 (ie interpolated from graph). Something like 3.000E-10 (not a valid number but used it to illustrate what the number should look like). I like to put in the original numbers every now & then to check the formula....so if the 1.5 and the 2.5 numbers are interpolated correctly then I know the other numbers should be on. What are your thoughts?
 
Upvote 0
yes...excellent...your interpolation column looks like what I want...how do I put in that formula?
 
Upvote 0
After I looked at your number a little closer...in your extrapolated column...it looks like you just split the difference between the two values....the exponential curve doesn't work like that. It would work with a linear function...but not here. The number has to be extrapolated from the exponential curve formula.
 
Upvote 0
Rail said:
After I looked at your number a little closer...in your extrapolated column...it looks like you just split the difference between the two values....the exponential curve doesn't work like that. It would work with a linear function...but not here. The number has to be extrapolated from the exponential curve formula.

Hi Rail!
its a complicated program to make extrapolation(to get values outside the known values) errors are huge. but there are a lot of algorithm for this. the linear interpolation between known values gives a fair value and its simple.
it assumes that the two consecutive points are connected by a line, thus
the unknown one lies in the said line.
Ill pm you if ill find back my interpolation program.
It has been 5 years that I didnt use that. In my actual practice as Engineer, that is the exact proces that gives me fair value with less error.
But if you want to be accurate enough then give me some time.

have a good day!
 
Upvote 0
hi!
As I have posted earlier, interpolation is complicated algorithm in numerical anlysis. But more or less I have one code in here. this uses the spline method of interpolation.
This has a very high acuraccy on values within the given data.
I have not fully tested this on values outside it.
see below.
Book1
ABCDEF
4XvaluesYvalueSplineinterpolationErrorlook?forans
50.51.5090E-091.509E-090.00%7.55.231E-11
60.751.1110E-091.111E-090.00%84.7522E-11
718.5360E-108.536E-100.00%151.711E-11
81.55.0010E-105.001E-100.00%
92.52.6470E-102.647E-100.00%
103.51.7880E-101.788E-100.00%
114.51.2060E-101.206E-100.00%
127.55.2310E-115.231E-110.00%
13151.7110E-111.711E-110.00%
14251.2480E-111.248E-110.00%
15353.7370E-113.737E-110.00%
16456.7060E-116.706E-110.00%
Sheet1



the code..........<font face=Courier New><SPAN style="color:#00007F">Dim</SPAN> xRaw()<SPAN style="color:#00007F">As</SPAN><SPAN style="color:#00007F">Double</SPAN><SPAN style="color:#00007F">Dim</SPAN> yRaw()<SPAN style="color:#00007F">As</SPAN><SPAN style="color:#00007F">Double</SPAN><SPAN style="color:#00007F">Dim</SPAN> y2Raw()<SPAN style="color:#00007F">As</SPAN><SPAN style="color:#00007F">Double</SPAN><SPAN style="color:#00007F">Function</SPAN> Interpolate(X<SPAN style="color:#00007F">As</SPAN> Range, Y<SPAN style="color:#00007F">As</SPAN> Range, LookFor<SPAN style="color:#00007F">As</SPAN><SPAN style="color:#00007F">Double</SPAN>)<SPAN style="color:#00007F">As</SPAN><SPAN style="color:#00007F">Double</SPAN>
    <SPAN style="color:#00007F">Dim</SPAN> i<SPAN style="color:#00007F">As</SPAN><SPAN style="color:#00007F">Long</SPAN>
    <SPAN style="color:#00007F">Dim</SPAN> v<SPAN style="color:#00007F">As</SPAN><SPAN style="color:#00007F">Double</SPAN>
    <SPAN style="color:#00007F">Dim</SPAN> yp1<SPAN style="color:#00007F">As</SPAN><SPAN style="color:#00007F">Double</SPAN>
    <SPAN style="color:#00007F">Dim</SPAN> ypn<SPAN style="color:#00007F">As</SPAN><SPAN style="color:#00007F">Double</SPAN>
    <SPAN style="color:#00007F">Dim</SPAN> c<SPAN style="color:#00007F">As</SPAN> Range
    <SPAN style="color:#00007F">Dim</SPAN> NRow<SPAN style="color:#00007F">As</SPAN><SPAN style="color:#00007F">Integer</SPAN>

NRow = X.Cells.Count<SPAN style="color:#00007F">ReDim</SPAN> xRaw(NRow - 1)<SPAN style="color:#00007F">As</SPAN><SPAN style="color:#00007F">Double</SPAN><SPAN style="color:#00007F">ReDim</SPAN> yRaw(NRow - 1)<SPAN style="color:#00007F">As</SPAN><SPAN style="color:#00007F">Double</SPAN><SPAN style="color:#00007F">ReDim</SPAN> y2Raw(NRow - 1)<SPAN style="color:#00007F">As</SPAN><SPAN style="color:#00007F">Double</SPAN>
    
    yp1 = 1E+30
    ypn = 1E+30
i = 0
    <SPAN style="color:#00007F">For</SPAN><SPAN style="color:#00007F">Each</SPAN> c<SPAN style="color:#00007F">In</SPAN> X
        xRaw(i) = c
        i = i + 1
    <SPAN style="color:#00007F">Next</SPAN> c
i = 0
    <SPAN style="color:#00007F">For</SPAN><SPAN style="color:#00007F">Each</SPAN> c<SPAN style="color:#00007F">In</SPAN> Y
        yRaw(i) = c
        i = i + 1
    <SPAN style="color:#00007F">Next</SPAN> c
    SplineCompute2nDerivative xRaw, yRaw, X.Cells.Count, yp1, ypn, y2Raw
    Interpolate = Splint(xRaw, yRaw, y2Raw, X.Cells.Count, LookFor)<SPAN style="color:#00007F">End</SPAN><SPAN style="color:#00007F">Function</SPAN><SPAN style="color:#00007F">Private</SPAN><SPAN style="color:#00007F">Function</SPAN> Splint(xa<SPAN style="color:#00007F">As</SPAN><SPAN style="color:#00007F">Variant</SPAN>, ya<SPAN style="color:#00007F">As</SPAN><SPAN style="color:#00007F">Variant</SPAN>, y2a<SPAN style="color:#00007F">As</SPAN><SPAN style="color:#00007F">Variant</SPAN>, n<SPAN style="color:#00007F">As</SPAN><SPAN style="color:#00007F">Long</SPAN>,<SPAN style="color:#00007F">ByVal</SPAN> X<SPAN style="color:#00007F">As</SPAN><SPAN style="color:#00007F">Double</SPAN>)<SPAN style="color:#00007F">As</SPAN><SPAN style="color:#00007F">Double</SPAN>

    <SPAN style="color:#00007F">Dim</SPAN> klo<SPAN style="color:#00007F">As</SPAN><SPAN style="color:#00007F">Long</SPAN>, khi<SPAN style="color:#00007F">As</SPAN><SPAN style="color:#00007F">Long</SPAN>, k<SPAN style="color:#00007F">As</SPAN><SPAN style="color:#00007F">Long</SPAN>
    <SPAN style="color:#00007F">Dim</SPAN> h<SPAN style="color:#00007F">As</SPAN><SPAN style="color:#00007F">Double</SPAN>, b<SPAN style="color:#00007F">As</SPAN><SPAN style="color:#00007F">Double</SPAN>, a<SPAN style="color:#00007F">As</SPAN><SPAN style="color:#00007F">Double</SPAN>

    klo = 0
    khi = n - 1
    <SPAN style="color:#00007F">While</SPAN> khi - klo > 1
        k = (khi + klo) / 2
        <SPAN style="color:#00007F">If</SPAN> xa(k) > X<SPAN style="color:#00007F">Then</SPAN> khi = k Else: klo = k
    <SPAN style="color:#00007F">Wend</SPAN>
    h = xa(khi) - xa(klo)
    <SPAN style="color:#00007F">If</SPAN> h = 0#<SPAN style="color:#00007F">Then</SPAN> MsgBox ("Bad xa input to routine Splint"):<SPAN style="color:#00007F">Exit</SPAN><SPAN style="color:#00007F">Function</SPAN><SPAN style="color:#007F00">'error handling for x1=x2</SPAN>
    a = (xa(khi) - X) / h
    b = (X - xa(klo)) / h
    Splint = a * ya(klo) + b * ya(khi) + ((a * a * a - a) * y2a(klo) + (b * b * b - b) * y2a(khi)) * (h * h) / 6#<SPAN style="color:#00007F">End</SPAN><SPAN style="color:#00007F">Function</SPAN><SPAN style="color:#00007F">Private</SPAN><SPAN style="color:#00007F">Sub</SPAN> SplineCompute2nDerivative(X<SPAN style="color:#00007F">As</SPAN><SPAN style="color:#00007F">Variant</SPAN>, Y<SPAN style="color:#00007F">As</SPAN><SPAN style="color:#00007F">Variant</SPAN>, n<SPAN style="color:#00007F">As</SPAN><SPAN style="color:#00007F">Long</SPAN>, yp1<SPAN style="color:#00007F">As</SPAN><SPAN style="color:#00007F">Double</SPAN>, ypn<SPAN style="color:#00007F">As</SPAN><SPAN style="color:#00007F">Double</SPAN>, y2<SPAN style="color:#00007F">As</SPAN><SPAN style="color:#00007F">Variant</SPAN>)
    
    <SPAN style="color:#00007F">Dim</SPAN> i<SPAN style="color:#00007F">As</SPAN><SPAN style="color:#00007F">Long</SPAN>, k<SPAN style="color:#00007F">As</SPAN><SPAN style="color:#00007F">Long</SPAN>
    <SPAN style="color:#00007F">Dim</SPAN> p<SPAN style="color:#00007F">As</SPAN><SPAN style="color:#00007F">Double</SPAN>, qn<SPAN style="color:#00007F">As</SPAN><SPAN style="color:#00007F">Double</SPAN>, sig<SPAN style="color:#00007F">As</SPAN><SPAN style="color:#00007F">Double</SPAN>, un<SPAN style="color:#00007F">As</SPAN><SPAN style="color:#00007F">Double</SPAN>
    <SPAN style="color:#00007F">ReDim</SPAN> u(n - 1)<SPAN style="color:#00007F">As</SPAN><SPAN style="color:#00007F">Double</SPAN>

    <SPAN style="color:#00007F">If</SPAN> yp1 > 9.9E+29<SPAN style="color:#00007F">Then</SPAN>
        y2(0) = 0#
        u(0) = 0#
    <SPAN style="color:#00007F">Else</SPAN>
        y2(0) = -0.5
        u(0) = (3# / (X(1) - X(0))) * ((Y(1) - Y(0)) / (X(1) - X(0)) - yp1)
    <SPAN style="color:#00007F">End</SPAN><SPAN style="color:#00007F">If</SPAN>

    <SPAN style="color:#00007F">For</SPAN> i = 1<SPAN style="color:#00007F">To</SPAN> n - 2
        sig = (X(i) - X(i - 1)) / (X(i + 1) - X(i - 1))
        p = sig * y2(i - 1) + 2#
        y2(i) = (sig - 1#) / p
        u(i) = (Y(i + 1) - Y(i)) / (X(i + 1) - X(i)) - (Y(i) - Y(i - 1)) / (X(i) - X(i - 1))
        u(i) = (6# * u(i) / (X(i + 1) - X(i - 1)) - sig * u(i - 1)) / p
    <SPAN style="color:#00007F">Next</SPAN> i
    <SPAN style="color:#00007F">If</SPAN> ypn > 9.9E+29<SPAN style="color:#00007F">Then</SPAN>
        qn = 0
        un = 0#
    <SPAN style="color:#00007F">Else</SPAN>
        qn = 0.5
        un = (3# / (X(n) - X(n - 1))) * (ypn - (Y(n) - Y(n - 1)) / (X(n) - X(n - 1)))
    <SPAN style="color:#00007F">End</SPAN><SPAN style="color:#00007F">If</SPAN>
    y2(n - 1) = (un - qn * u(n - 1)) / (qn * y2(n - 1) + 1#)
    <SPAN style="color:#00007F">For</SPAN> k = n - 2<SPAN style="color:#00007F">To</SPAN> 0<SPAN style="color:#00007F">Step</SPAN> -1
        y2(k) = y2(k) * y2(k + 1) + u(k)
    <SPAN style="color:#00007F">Next</SPAN><SPAN style="color:#00007F">End</SPAN><SPAN style="color:#00007F">Sub</SPAN></FONT>
 
Upvote 0

Forum statistics

Threads
1,215,633
Messages
6,125,928
Members
449,274
Latest member
mrcsbenson

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top