2
$\begingroup$

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)?

3 Answers 3

0

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]

  • 0
    No problem... (but you c$a$n still accept it if you want to).2012-01-04
1

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.

  • 0
    @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$2012-01-02
0

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.