# $e^x-x-4$equating with zero

I want to find out the values of x where the $f(x) = e^x-x-4$ will equal zero.

My problem by solving this myself is that I cannot use logarithm natural (ln) because I have a normal x:

$f(x) = e^x - x - 4$

$f(x) = 0$

$\Rightarrow e^x - x -4 = 0 (| +x | +4)$

$\Rightarrow e^x = x + 4$

Failed solution one: $e^x = x + 4 | ^{(-x)}$

$e^0 = (x + 4)^{(-x)}$

$1 = (x + 4)^{(-x)}$ ?

Failed solution two:

$e^x = x + 4 | \ln$

$\Rightarrow x = \ln(x) + \ln(4)$ ?

What is the solution?

Cheers bodo

-
In your failed solution two, you can't say $\ln(x+4)=\ln(x)+\ln(4)$. – coffeemath Dec 12 '12 at 16:46
To get more intuition try to solve $e^x = x+4$ by plotting the curves. You can see that positive solution will be between 1 and 2, and negative one will be around -4. – karakfa Dec 12 '12 at 17:21

## 2 Answers

This kind of equations generally have no closed-form solution.

It is often possible to manipulate the equation into a form that allows a solution to be written in terms of Lambert's W function, but that's usually not a major improvement from a practical point of view.

You will need to approximate the solution numerically.

Solution with $W$: Set $y = -e^x$. Then $x-e^x = -4$ becomes $$\log(-y)+y = -4$$ Exponentiating both sides get $$-ye^y = e^{-4}$$ so by definition of the $W$ function we have $y=W(-e^{-4})$. Plug into the definition of $y$ and we get $$x = \log(-W(-e^{-4}))$$ which produces one solution for each of the two branches of $W$. Enlightening, right?

-
thank you for the answer. Than I will have to get the answer through simplification and test insertion. – bodokaiser Dec 12 '12 at 16:45

If you just need a numerical solution, then there are many methods available. For example, Newton's Method converges quite rapidly on each root. First, if $f(x) = e^x - x - 4$, then $f'(x) = e^x - 1$. Since $f'$ has only the root $x=0$, we can infer that $f$ has at most two roots, one on either side of $0$. Set up the recursive formula for Newton's Method: $$x_{n+1} = x_n - \frac{f(x_n)}{f'(x_n)} = x_n - \frac{e^{x_n} - x_n - 4}{e^{x_n}-1}.$$ With initial guess $x_0 = -4$, and 4 iterations, we find a solution stable to 14 decimal digits: $-3.98133937091132$. With initial guess $x_0=2$, we get: $1.74903138601270$ (stable to 14 digits after 6 iterations).

-