Linearizing an equation containing both $x$ and $\ln x$

465 Views Asked by At

The equation of interest is of the form: $$ k_1 \ln(y/x) = k_2 x $$ And I am wondering how can one linearize this equation for $x.$ Splitting the $\ln$ function would give something along:

$$ k_1 \ln y = k_2 x + k_1 \ln x $$ Taking the $\exp$ on both sides doesn't seem to help much either (not even for the original equation, as one would still have non-linear terms like $\exp{k_2 x}$).

  • Is a Taylor expand of the $\ln x$ a good idea here?
  • If not, what other manipulations can one try with such equation?
  • Indeed a numerical method should always work in such cases, but what method is advised for such forms?
3

There are 3 best solutions below

2
On BEST ANSWER

First point

Suppose that you have $n$ data points $(x_i,y_i)$ on the basis of which you want to fit the model $$y=x \,e^{a x}$$ which is nonlinear with respect to the parameter $a$. So, in principle, to adjust parameter $a$, you need to perform a nonlinear regression and this requires a reasonable estimate to start iteration with. You can estimate this parameter writing $$\log\big(\frac yx\big) =a x$$ which corresponds now to a linear model with no intercept $$z=a x$$ provided you define $$z_i=\log\big(\frac {y_i}{x_i}\big)$$ Doing so, a graphical method would immediately show the order of magnitude of the parameter you are looking for (as well if the model looks to fit the data) but more precise would be to use (as Jp McCarthy commented) the formula derived from the normal equation that is to say $$a=\frac{\sum_{i=1}^n x_i\, z_i}{\sum_{i=1}^n x_i^2}=\frac{\sum_{i=1}^n x_i\, \log\big(\frac {y_i}{x_i}\big)}{\sum_{i=1}^n x_i^2}$$ But doing so, what you minimized is the sum of the squares related to the $\log\big(\frac {y_i}{x_i}\big)$ while your real goal is to minimize the sum of the squares related to the $y_i$ since these are the values which have been measured and need to be fitted.

But now, you have in hands all what is required for a nonlinear regression which, starting from the first obtained estimate of parameter $a$, will probably converge in a very small number of iterations.

Second point

Suppose that you know the value of parameter $a$. For a new value of $x$, you easily get the value of $y$ (just apply the formula) but, for a value of $y$, you cannot get so easily the corresponding value of $x$ (for sure, from a plot of the function, you could read it more or less accuratly).

Rewrite the equation as $$a\,y=a\,x \,e^{a x}$$ nd you see here all the elements which constitute Lambert function and the solution is just given by $$x=\frac{1}{a}W(a y)$$ Lambert function is very important in many application and can be accurately estimated using series (have a look at http://en.wikipedia.org/wiki/Lambert_W_function) and, if cannot use Lambert function per se, a Newton method would polish the root in very few iterations.

Example for illustration purposes

I generated $20$ data points ($i$ from $1$ to $20$) using $x_i=i$ and $$y_i= x_i e^{0.1234 x_i} \left(1+0.2 \times (-1)^i\right)$$ Performing the first step, we obtained $a=0.122613$ to which corresponds $R^2=0.981159$ and the associated error for the parameter is $0.0040$. Recomputing the $y_i$ would then lead to a sum of squares on the $y$'s equal to $7525.89$.

Starting from here, the nonlinear regression leads to $a=0.125616$ to which corresponds $R^2=0.965508$ and the associated error for the parameter is $0.0025$. The corresponding sum of squares is $6980.35$.

Now, suppose that we want $x$ such that $y=1000$. Using Lambert function the result is immediate $$x=\frac{1}{0.125616}W(125.616)=28.3618$$ But, let us admit that we cannot use Lambert function; in the Wikipedia page, they give the first order approximation $$W(z)\approx L_1-L_2+\frac{L_2}{L_1}+\frac{L_2(L_2-2)}{2L_1^2}+\frac{L_2(2L_2^2-9L_2+6)}{6L_1^3}+\cdots$$ where $L_1=\log(z)$ and $L_2=\log(L_1)$. So, for $z=123.5616$, this gives $W(125.616)\approx 3.56190$ that is to say $z=28.3554$ which is not bad at all.

4
On

Hint: Transform it into an explicit function in terms of $x$ first.

$$\ln{\frac{y}{x}}=\frac{k_2}{k_1}x\\ \frac{y}{x}=e^{\frac{k_2}{k_1}x}\\ y=xe^{\frac{k_2}{k_1}x}$$

2
On

Is it not in linear form already:

$$\underbrace{\ln\left(\frac{y}{x}\right)}_{Y}=\underbrace{\frac{k_2}{k_1}\cdot x}_{m\cdot X}.$$

Plot $\ln(y/x)$ vs $x$ and you have a straight line... $x>0$ by the original relationship.