How to solve $x + 3^x = 4$ analytically? I tried to solve the problem of $x + 3^x = 4$. I know that we can find it that $x = 1$ intuitively. I just want to know how to solve it using mathematic formula.
I have learned a little bit about Lambert W function. I've tried to rewrite the formula to become:
\begin{align}
1 &= (4-x) \, e ^{-x \ln(3)} \\
1 &= 4 \, e ^{-x \ln(3)} - x \, e ^{-x \ln(3)} \\
1 &- 4 \, e ^{-x \ln(3)} = -x \, e ^{-x \ln(3)} \\
\ln(3) & - 4 \, \ln(3) \, e ^{-x \ln(3)} = -x \ln(3) \, e ^{-x \, \ln(3)}
\end{align}
Until that last part, I got confused how to combine the $x$ variables at both sides. That's why I got stuck. Any idea how to combine it? Or is there any part of my solution need to be corrected? Thank you.
 A: To get a solution using the Lambert $W$ function which has $z=W(ze^z)$:
$$x+3^x=4$$
$$x-4 = -81\cdot3^{x-4}$$
$$\log_e(3)(x-4) = -81\log_e(3)\cdot e^{\log_e(3)(x-4)}$$
$$-\log_e(3)(x-4)\cdot e^{-\log_e(3)(x-4)}= 81\log_e(3)$$
$$-\log_e(3)(x-4) = W\left(81\log_e(3)\right)$$
$$x=4 - \dfrac{W\left(81\log_e(3)\right)}{\log_e(3)}$$
A: By the methods started by the proposer one can show that the equation in question is part of a more general set given by $x + a^{x} = b$ which has the soltion
$$x = b - \frac{W_{0}(a^{b} \, \ln(a))}{\ln(a)}.$$
The proof of which can be seen by use of $a^{x} = e^{x \, \ln(a)}$ and $x \, e^{x} = t$ has the solution $t = W(x)$, where $W(z)$ is the Lambert W-function, where $W_{0}(x)$ is defined as th ereal solution for $x \geq -1/e$, and is: 
\begin{align}
x + a^{x} &= b \\
(x - b) &= - a^x = - e^{(x-b) \, \ln(a) + b \, \ln(a)} \\
-(x - b) \, \ln(a) \, e^{- (x-b) \, \ln(a)} &= a^{b} \, \ln(a) \\
- (x-b) \, \ln(a) &= W_{0}(a^{b} \, \ln(a)) \\
x &= b - \frac{W_{0}(a^{b} \, \ln(a))}{\ln(a)}.
\end{align}
For this particular problem one can use the property $W(x \, \ln(x)) = \ln(x)$ in such a way that $W(3^{4} \, \ln(3)) = W(27 \, \ln(27)) = \ln(27) = 3 \, \ln(3)$. For the equation $x + 3^{x} = 4$, which from the general solution is $a=3$ and $b=4$ yields
\begin{align}
x &= 4 - \frac{W_{0}(81 \, \ln(3))}{\ln(3)} \\
&= 4 - \frac{3 \, \ln(3)}{\ln(3)} \\
&= 1.
\end{align}
A: To hell with the formulas. As  the function $x+3^x$ is increasing the solution $x=1$ is unique. 
A: I am assuming we are dealing with the Real domain i.e. $ \{x|x \in \mathbb{R} \} $
Rearrange equation $ x + 3^x = 4$ so that there is a zero on one side: 
$$ x + 3^x - 4 = 0 $$ 
Let $ f(x) = x + 3^x - 4 = 0 $
Find potential turning points by solving for the derivative $ \frac{d}{dx} [f(x)] $ and then solving for $\frac{d}{dx} [f(x)] = 0 $ 
Apply addition rule: 
$ \frac{d}{dx} [x + 3^x - 4] = \frac{d}{dx}[x] + \frac{d}{dx} [3^x] - \frac{d}{dx} [4] $
Use properties $ \frac{d}{dx}[kx] = k \: and \: \frac{d}{dx}[c] = 0 $ 
$ = 1 + \frac{d}{dx} [3^x] - 0 $ 
$ = 1 + \frac{d}{dx} [e^{\ln(3)*x}]$ , using the fact that $ \frac{d}{dx} [e^x] = e^x $ 
and applying the chain rule $\frac{d}{dx}[f(g(x))] = f'g(x) * g'(x) $ 
$ 1 + \frac{d}{dx}[e^{\ln(3)*x}]  = 1 + e^{\ln(3)*x} * \ln(3) $

$ = 1 + 3^x * \ln(3) $

Now solve for $ 1 + 3^x * ln(3)  = 0 $ : 
$ 3^x * \ln(3) = -1 $ 
$ 3^x = -\frac{1}{\ln(3)} $ , negative number, no solutions in the real domain thus there are no stationary points and no turning points. 
As a consequence of Rolle's Theorem: 
$ \text{#Roots} \leq \text{#turningPoints} + 1 $ 
Thus, $ \text{max#OfRoots} = 0 + 1 = 1 $ 
Therefore, the only solution in the real domain is $ x = 1$ 
