Finding the equation of a rational function from a set of points

1k Views Asked by At

I want to fit a curve onto a set of points. The curve should look like a log or square root function.I want the function to be specifically in this format (per the requirements of my supervisor):

$\frac{ax}{b+x}$

The set of points are: (1,65), (200,70), (800,75)

What I did was use two of the points to build a system of equations and solve for a and b. The function I come up with passes through the points but has oscillations in between the points and does not have the shape of a log/square root function. I was recommended to use Lineweaver-Burke plot to deal with this problem. I did some reading on the subject but could not manage to understand how I can use this in this instance.

Any advice on how to fit a rational function for the set of points provided is appreciated.

2

There are 2 best solutions below

0
On BEST ANSWER

Let me address the general problem where you have $n$ data points $(x_i,y_i)$ for $i=1,2,\cdots,n$ and you want to fit, in the least square sense, the model $$y=\frac {a x}{b+x}$$ which is nonlinear (because of $b$). So, at a time, nonlinear regression will be required which means that "reasonable" estimates will need to be provided.

You can have these estimates writing $$\frac 1 y=\frac b a \frac 1 x+\frac 1 a$$ So, in a first step, define $t_i=\frac 1 {x_i}$ and $z_i=\frac 1 {y_i}$ making the model to be $$z=\alpha t+\beta$$ and a basic linear regression will give $(\alpha,\beta)$ from which the estimates $a_*=\frac 1 \beta$ and $b_*=\frac \alpha \beta$.

But, since what is measured is $y$ and not any of its possible tranforms, nonlinear regression will consist in the minimization of $$SSQ=\sum_{i=1}^n \left(\frac {a x_i}{b+x_i}-y_i \right)^2$$ If you do not access a nonlinear regression software, compute the partial derivatives of $SSQ$ $$\frac{\partial SSQ}{\partial a}=2\sum_{i=1}^n \frac {x_i\left(\frac {a x_i}{b+x_i}-y_i \right)}{b+x_i}\tag 1$$ $$\frac{\partial SSQ}{\partial b}=-2a\sum_{i=1}^n\frac {x_i\left(\frac {a x_i}{b+x_i}-y_i \right)}{(b+x_i)^2}\tag 2$$

Setting these derivatives equal to $0$, $(1)$ gives $$a(b)=\frac{\sum_{i=1}^n \frac {x_i y_i}{b+x_i} } {\sum_{i=1}^n\frac {x^2_i}{(b+x_i)^2} } \tag 3$$ and your are left with the equation (from $(2)$) $$\sum_{i=1}^n\frac {x_i\left(a(b)\frac { x_i}{b+x_i}-y_i \right)}{(b+x_i)^2}=0\tag 4$$ which can be solved using graphics or Newton method for example since you already have the starting point $b_*$.

1
On

Caution: As Claude Leibovici's comment says, this is only good for obtaining estimates of $(a,b)$ for $y$.

Let $y=\frac{ax}{b+x}$. Then for some input $x$ and output $y$ we have \begin{align} \frac{ax}{b+x} &= y\\ ax-by&=xy \end{align}

If we want to fit the points $(1,65),(200,70),$ and $(800,75)$ we can set up the following system of $3$ equations and $2$ unknowns:

\begin{align} a-65b &= 65\\ 200x-70b &= 14000\\ 800x-75b &= 60000\\ \end{align}

We can rewrite this in the form of the matrix equation $Ax=b$ as

$$\pmatrix{1 & -65\\ 200 & -70\\ 800 & -75}\pmatrix{a\\b} = \pmatrix{65\\14000\\60000}$$

which does not have a solution. However, we can find a least squares approximation by solving $A^TAx=A^Tb$. I went ahead and did the computation in MATLAB, yielding \begin{align} a &\approx 75.5 \\ b &\approx 7.31 \end{align} Here is a picture of the curve in black with the points in red. Plot of least squares estimated curve.

This is about as far as my knowledge extends. Perhaps someone can comment further on whether or not this is a good fit (looking at things such as residuals). Click here or here for some readings I quickly found through google.