how to find x in $ax + e^x = k$ in my project i have faced with a formula that I can't solve it. a very simplified and basic version of that equation can be rewritten as $ax + e^x = k$. please help me to solve this elementary calculus equation.
 A: Let $f(x) = ax+e^x-k$, and solve $f(x) = 0$.
Newton's method would be a reasonable first start.
The update for $x$ would be $x_{n+1} = x_n - \frac{f(x_n)}{f'(x_n)} = \frac{(x_n-1)e^{x_n}+k}{e^{x_n}+a}$.
A: Hint : 
1.let $\large{f(x)=\frac{k-e^x}{a}}$ by numerical method find fix point of $f$ 
2.
or let $\large{g(x)=ax + e^x - k}$  by numerical method find roots of $g$ 
A:  myfunc=@(a,x,k) a*x+exp(x)-k;
>> a=1;
>> k=3;
>> fun=@(x) myfunc(a,x,k);
>> x=fzero(fun,0.1,k)

x =

    0.7921

for different value of a and k ,you get different root.or you can  use Lambert W function.thanks i hope it will help you
you dont need to use extra parameter $k$,simply do like this
x=fzero(fun,0.1)

x =

    0.7921

A: Your equation can be solved with the Lambert $W$ function or the simpler single-valued Wright $\omega$ function:
$$x = \frac{k}{a} - W_0(e^{k/a}/a) = \frac{k}{a} - \omega(k/a-\ln a)$$
for $x, a, k \in \mathbb{Z}$ and where $W_0$ is the upper (principal) branch of the Lambert $W$ function. As @Raskolnikov suggests, these are still not "elementary," though there will be exact solutions for particular combinations of $a$ and $k$ (e.g., $x = 0$ for $a = k = 1$). See my answer to this recent question for some suggestions on computing numeric solutions. The 2012 paper by Lawrence, Corless, and Jeffrey is recommended reading if you end up needing to implement a method to evaluate the Wright $\omega$ function in part or all of the complex plane.
A: Let $x=\log(u)$ then
$$
ax+e^x=k\mapsto a\log(u)+u=k
$$
divide by $a$, exponentiate, divide by $a$ again:
$$
(u/a)e^{u/a}=\frac1ae^{k/a}
$$
The Lambert-W function is the inverse of $x\mapsto xe^x$, so we get
$$
\begin{align}
u/a&=\mathrm{W}\left(\frac1ae^{k/a}\right)\\
u&=a\mathrm{W}\left(\frac1ae^{k/a}\right)\\
x&=\log\left(a\mathrm{W}\left(\frac1ae^{k/a}\right)\right)\\
&=\frac ka-\mathrm{W}\left(\frac1ae^{k/a}\right)
\end{align}
$$
The last formula follows from $u=e^x$ and $ax+u=k$

Numerical Iteration for Lambert W
Using Newton's method, we get the iteration
$$
w_{\text{new}}=\frac{xe^{-w}+w^2}{w+1}
$$
Initial Values
For the principal branch when $-1/e\le x\lt0$ and when $0\le x\le10$, use
$w=0$.  When $x\gt10$, use $w=\log(x)-\log(\log(x))$.
For the non-principal brance, if $x\in[-1/e,-0.1]$, use $w=-2$; and
if $x\in(-0.1,0)$, use $w=\log(-x)-\log(-\log(-x))$.
