# Interpolation to a power function

We have an experiment which have the variables $x$ and $y$. $x$ and $y$ can be measured into pair $(x_i,y_i)$. Now I'm finding a way to interpolate it into a power function $y=a+bx^c$. Which $a,b,c$ are real number (and $a>0, b>0, c>0$). How to find that function? (among $a,b,c$; $a$ is the number I need the most). For example, we did the experiment many times and have $(x_1,y_1)=(1,3)$; $(x_2,y_2)=(3,5)$; $(x_3,y_3)=(5,8)$; $(x_4,y_4)=(10,11)$

If possible, how can we do that in Matlab (or similar programming software)?

-

What you want is Constrained Nonlinear Least Squares.
In Maple you could do

X:= [1,3,5,10]: Y:= [3,5,8,11]:

Residuals:= [seq(a+b*X[i]^c - Y[i], i=1..4)]:

Optimization[LSSolve](Residuals, {a >= 0, b >= 0,c >= 0});

[.308370175847439200, [a = 0., b = 2.91266785479164, c = .582530468246663]]

I'm pretty sure Matlab has similar functionality.

-

There is no exact answer for an overloaded system, that is a system where you have more "solutions" (x, y pairs) than unknowns. The problem can be solved exactly where you have a pair for each unknown in your case that would mean having three pairs for the three unkowns. If you have more than enough answers and they are experimentally gained then you have to use an inexact method known as the method of least squares or some other method to minimize the error in the interpolated function.

The idea is to construct a "cost" function to determine how expensive for the function to be away from a point.

Excel can do this with a power fit.

-
Agree. The MS Excel can do that with $y=bx^c$. I did the experiment and have 14 (x,y) pairs in the end. I thought about the y'=y-a and use MS excel to have the interpolating function, but by doing that there's no way I can attain the desired value of a, so there's no exact value of y' to put in Excel. (as we can see we have only values of x and y) Thanks for your answer. –  linkgreencold Jan 2 '12 at 20:35
@linkgreencold: You can do it in Excel by making a couple cells be the parameters (in your case, a,b,c) and a column of your measured data. Then make a column of your calculated $y_i$'s based on $a,b,c,x_i$. Sum the squared errors and ask Goal Seek to minimize changing $a,b,c$ –  Ross Millikan Jan 2 '12 at 22:01

Just for completeness, in MATLAB the command is

f=fit(x,y,fittype('power2');

where (x,y) should be column vectors. In Mathematica the command is

FindFit[Transpose[{x, y}], {a + b t^c}, {a, b, c}, t]

-
Thank you, I used the fit function and had the pretty satisfied answer. Wanna vote up your answer but haven't enough reputation point yet. –  linkgreencold Jan 4 '12 at 11:14
No problem... (but you can still accept it if you want to). –  yohBS Jan 4 '12 at 15:00