I have equations for two lines, one of which is linear and the other is logarithmic, ie:

$$y = m_1 x + c_1$$

$$y = m_2 \cdot \ln(x) + c_2$$

..and I need to find out where (if at all) these lines intersect. I realise that I need to solve:

$$ m_1 \cdot x + c_1 = m_2 \cdot \ln(x) + c_2$$

..for $x$, but apart from shuffling the constants around I'm not sure how to do this.

Is there a general solution to this problem?



There is no algebraic solution. You can solve this numerically. As log changes so slowly, iterative methods converge quickly.

  • $\begingroup$ Thanks for this. I put together a numeric solution which works fine. It's good to know I wasn't missing an easy way to do this algebraically. $\endgroup$ – Simon Andrews Mar 9 '11 at 11:00

The general solution involves the Lambert W function, whose defining equation is $z = W(z)e^{W(z)}$ for complex numbers $z$. If either $m_1$ or $m_2$ is zero in the given problem, then the solution is elementary, so suppose $m_1,m_2 \neq 0$. Then $$ m_1 x + c_1 = m_2 \ln x + c_2 $$ can be rewritten as $$ -\frac{m_1}{m_2}e^{(c_1-c_2)/m_2} = -\frac{m_1 x}{m_2} e^{-m_1 x / m_2}, $$ which has the solution $$ -\frac{m_1 x}{m_2} = W\left(-\frac{m_1}{m_2}e^{(c_1-c_2)/m_2}\right), $$ or $$ x = -\frac{m_2}{m_1} W\left(-\frac{m_1}{m_2}e^{(c_1-c_2)/m_2}\right). $$ For instance, if $m_1=1$, $m_2=-1$, and $c_1=c_2=0$, this gives $x=W(1)=\Omega=0.56714329...$ (the Omega constant), which is correct, since $\Omega = -\ln\Omega$.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.