# Error $\Delta A$ in Least Squares best fit of data to hyperbola $y=B/(x-A)$

Problem description.
Let there be given a set of real-valued data points $\,(x_i,y_i)\,$. Find the Least Squares best fit of these points to a hyperbola $\;y = B/(x-A)\;$, written as $\;y(x-A)-B=0\;$: $$\sum_i \left[\,y_i(x_i-A) - B\,\right]^2 = \mbox{minimum}(A,B)$$ The minimum is found with help of partial differentiation, giving: $$\frac{\partial}{\partial A} \quad : \quad \left(\sum_i y_i^2\right) A + \left(\sum_i y_i\right) B = \sum_i x_i y_i^2 \\ \frac{\partial}{\partial B} \quad : \quad \left(\sum_i y_i\right) A + \left(\sum_i 1\right) B = \sum_i x_i y_i$$ The solution of this system of linear equations is: $$A = \frac{M_{22}R_1-M_{12}R_2}{M_{11}M_{22}-M_{12}^2} \quad ; \quad B = \frac{-M_{12}R_1+M_{11}R_2}{M_{11}M_{22}-M_{12}^2}$$ With: $$M_{11} = \sum_i y_i^2 \quad ; \quad M_{12} = \sum_i y_i \quad ; \quad M_{22} = \sum_i 1 \\ R_1 = \sum_i x_i y_i^2 \quad ; \quad R_2 = \sum_i x_i y_i$$ So far so good. We are especially interested in the value of $\,A\,$. But what bothers us is the error / the uncertainty in $\,A\,$, let's call it $\,\Delta A\,$.
Pictures say more than a thousand words. The red line on the left is the asymptote of the hyperbola, at $\,A\,$. In the same picture rightmost we see the data, enlarged for clarity in the picture on the right.

I really have no clue how to obtain a decent estimate for $\,\Delta A\,$ neither in theory or experimentally. I'm afraid that it is bad. But anyway, any help is highly appreciated!

• What are the scales on your pictures ? Or better, edit explicitly the numerical data. Nov 9, 2017 at 11:50
• @JJacquelin: Sorry. The data are my little secret at this moment. Because it concerns a highly speculative theory and I don't want to sound ridiculous before knowing myself what I'm talking about. Hence the phrase in the question: I'm afraid that it is bad. Nov 9, 2017 at 16:17

This is too long for a comment.

You must take care : what is measured is $y$ and then what you need to minimize is $$SSQ=\sum_{i=1}^n \left(\frac B{x_i-A}-y_i \right)^2 \tag 1$$ This is a nonlinear model and, as usual, you need some reasonable estimates of $A,B$ before starting the nonlinear regression.

You can easily have estimates making $$y=\frac B{x-A}\implies \frac 1y=\frac x B-\frac AB=ax+b$$ So, defining $z_i=\frac 1{y_i}$, a linear regression gives $a,b$ from which $B=\frac 1a$ and $A=-\frac ba$.

Now, start the nonlinear regression.

Edit

If you do not want to use a nonlinear regression, the problem can be solved in the following manner (taking into account the fact that the model is linear with respect to $B$).

Using the definition of $SSQ$ as in $(1)$, compte the partial derivatives and set them equal to $0$. This gives

$$SSQ'_{B}=0\implies B \sum_{i=1}^n \frac 1 {(x_i-A)^2}= \sum_{i=1}^n \frac {y_i} {(x_i-A)}\tag 2$$ $$SSQ'_{A}=0\implies B \sum_{i=1}^n \frac 1 {(x_i-A)^3}= \sum_{i=1}^n \frac {y_i} {(x_i-A)^2}\tag 3$$ Recombining $(2)$ and $(3)$, we then end with a single equation in $A$ $$F=\left(\sum_{i=1}^n \frac {y_i} {(x_i-A)}\right)\left(\sum_{i=1}^n \frac 1 {(x_i-A)^3}\right)-\left(\sum_{i=1}^n \frac {y_i} {(x_i-A)^2}\right)\left(\sum_{i=1}^n \frac 1 {(x_i-A)^2}\right)=0\tag 4$$ This last equation can be solved using Newton method using (if lazy) cental differences for the evaluation of $F'_A$ as, for example $$F'_A=\frac{F(1.001A)-F(0.999A)}{0.002 A}$$ If not lazy, the derivative $F'_A$ can easily be expressed analytically.

For sure, since you are concerned by only one branch of the hyperbola, you need to search for $A$ starting above the largest value of the $y_i$'s.

• Sorry, Claude. There is no way that I'm going to implement a nonlinear regression model with my humble home-made software. What I have done is an SSQ (what is it?) with $\,\sum_i (x_i-A-B/y_i)^2$ . Giving no significant other outcomes, when compared with the method presented in the question. Nov 9, 2017 at 16:26
• @HandeBruijn. I am almost ready to bet that, using the good estimates, we can do the work using Newton-Raphson method. I shall work that tomorrow morning and hopefully come back with something. As I wrote, what is measured is $y$ and not any of its possible transforms. Nov 9, 2017 at 16:30
• According to you: $$M(A,B) = \sum_i \left(\frac{B}{x_i-A}-y_i \right)^2$$ Newton-Raphson method, $k$-th iteration: $$\begin{bmatrix} \partial^2M/\partial A_k^2 & \partial^2M/\partial A_k\partial B_k \\ \partial^2M/\partial A_k\partial B_k & \partial^2M/\partial B_k^2 \end{bmatrix} \begin{bmatrix} A_{k+1}-A_k \\ B_{k+1}-B_k \end{bmatrix} = - \begin{bmatrix} \partial M/\partial A_k \\ \partial M/\partial B_k \end{bmatrix}$$ With $(A_0,B_0) =$ values from question. Is that right? Then I think I can manage it. Thanks. Nov 9, 2017 at 19:32
• @HandeBruijn. I think I can propose something easier. Just wait a few hours ! Cheers. Nov 9, 2017 at 20:57
• Since my upvotes are already exhausted I can't give you another one :-( Especially that single equation in $A$ sounds good. But there are several options now and I have to work through them (: programming) to decide which answer deserves the accept. Nov 10, 2017 at 16:00

In addition to Claude Leibovici's comment, an alternative way to obtain a first estimate :

From $y=\frac{B}{x-A} \quad\to\quad (x-A)y=B \quad\to\quad xy=B+Ay$

Reset your data with $\begin{cases}Y=xy\\X=y\end{cases}$

$$Y=B+AX$$ A linear regression gives approximate $A$ and $B$.

If not accurate enough, start a non-linear regression from those initial values.

• Good idea (+1)! Then I only have to figure out what the uncertainty in the slope $A$ is. Do you accidentally have an expression for that? Nov 9, 2017 at 16:20
• I have programmed your idea and it seems to work. Thanks! Nov 14, 2017 at 21:28