Constrained parameters in least square curve fitting

curvesleast squares

I have some data points that need to be fit to the curve defined by

$$y(x)=\frac{k}{(x+a)^2} – b$$

I have considered that it can be done by the least squares method. However, the analytical solution gives me a negative $a$, so it puts the first point on the left branch of this hyperbola and I need all the points to fit to the right branch, thus $a$ must be positive. All my points have positive $x$ and $y$ is non-increasing.

Is there any way to add this type of constraint to analytical solution?

I would also kindly appreciate any links to related and/or useful information on iterative numerical solution. I need to program everything manually for my mobile app, so I can't use any external software or libraries.

Best Answer

In any manner, your model is nonlinear with respect to parameters. So, why not to rewrite it as $$y(x)=\frac{k}{(x+\alpha^2)2} - b$$

Related Question