# Solving a non-linear equation

I am trying to fit data to an equation of this form using non-linear regression: $$y = 1 - \frac{a}{{\exp \left( {n\left( {x - {x_0}} \right)} \right)}}$$ I would like to select three sets of $(x, y)$ data and solve the above equation for $a$, $n$ and $x_0$ in order to improve the initial estimates of these parameters. I eliminated $a$ using the following expression: $$a = \left( {1 - {y_1}} \right)\exp \left( {n\left( {{x_1} - {x_0}} \right)} \right)$$ where $(x_1, y_1)$ is one of the selected data points and then back-substituted it to give: $${y_2} = 1 - \frac{{\left( {1 - {y_1}} \right)\exp \left( {n\left( {{x_1} - {x_0}} \right)} \right)}}{{\exp \left( {n\left( {{x_2} - {x_0}} \right)} \right)}}$$ where $(x_2, y_2)$ in another of the selected data points. This becomes $${y_2} = 1 - \left( {1 - {y_1}} \right)\exp \left( {n\left( {{x_1} - {x_2}} \right)} \right)$$ and thus $$n = \frac{1}{{{x_1} - {x_2}}}\ln \left( {\frac{{1 - {y_2}}}{{1 - {y_1}}}} \right)$$ If I use point $(x_3, y_3)$ instead I get: $$n = \frac{1}{{{x_1} - {x_3}}}\ln \left( {\frac{{1 - {y_3}}}{{1 - {y_1}}}} \right)$$ The problem is that I have two different expressions for $n$ but none for $x_0$ because it was eliminated along the way. I get a similar result if I eliminate $x_0$ first.

Is it possible to solve for $a$, $n$ and $x_0$ in this manner?

Many thanks!

Update: Thanks JJacquelin - I thought there might be redundancy somewhere but it was only when you rearranged the equation that it became obvious where it was. And thanks also for pointing out the transformation into a linear regression problem.

• JJacquelin showed how to get the parameters by linearization. Once you get them, you must continue with nonlinear regression since what is measured is $y$ and not $\log(1-y)$. – Claude Leibovici Mar 31 '18 at 7:22

$$y = 1 - \frac{a}{{\exp \left( {n\left( {x - {x_0}} \right)} \right)}}$$ $$1-y = a\exp \left( {-n\left( {x - {x_0}} \right)} \right)$$ $$\ln(1-y)=-n(x-x_0)+\ln(a)$$ This is a function on the form : $$Y=Ax+B \quad \text{ with }\quad \begin{cases} Y=\ln(1-y)\\ A=-n\\ B=n\,x_0+\ln(a) \end{cases}$$ So, there is no need for calculus such you did. Simply, transform your data $(x,y)$ into $(x,Y)$ in computing $Y=\ln(1-y)$ for each point. Then, carry out a linear regression to find the approximates of $A$ and $B$.
They are redondant parameters in your initial equation. That is the cause of the trouble that you encountered. $$y = 1 - \frac{a}{{\exp \left( {n(x - x_0)} \right)}} =1 - \frac{a\exp(n\,x_0) }{{\exp \left( {n\,x} \right)}}$$ $a\exp(nx_0)$ is a constant, thus $a,n,x_0$ are not independent. You can arbitrary chose a value for $x_0$ and then you obtain a value for $a$. Or you can arbitrary chose a value for $a$ and you obtain a value for $x_0$. The fitting will be exactly the same what ever your choice.