Find tangent line of $f(x)=e^x+2$ that passes through origin Defining the function:
$$f(x)=e^x+2$$
Find the point at which the line of the tangent passes through the origin.
I have found a graphical method and a numerical method of solving this, but no luck in solving it properly. I get stuck at trying to solve:
$$0=e^x+2.xe^x$$
 A: The tangent at $t$ can be expressed as
\begin{equation}
y = f'(t)(x-t) + f(t) = e^t(x-t) + e^t + 2.
\end{equation}
Now this should pass through the origin, hence we have
\begin{equation}
-t e^t + e^t + 2 = 0.
\end{equation}
In general, this does not have analytic solution, hence we need to solve this using some iterative numerical solution. I used a numerical method, which gives the answer: $1.4630555$.
There are hundreds of ways to solve this. Here's one method:
the following Python code will give the answer.
import scipy.optimize
from numpy import exp

def foo(x):
    return - x * exp(x) + exp(x) + 2

print(scipy.optimize.anderson(foo, 0.0))

You can solve the same problem using other methods in Python, or you can solve this using Matlab, too. (And there are still other methods!)
A: Given that the tangent line passes the origin, we have $f'(x) = \frac yx$, or
$$(x-1)e^{x-1}=\frac2e$$
Then, the solution is given by 
$$x = W\left( \frac2e\right) + 1 $$
where $W(t)$ is the Lambert function. Thus, the tangent line is 
$$y = \frac 2{W\left( \frac2e\right) }x$$
