Show that $g'(x)+g(x)-2e^x=0$ 
Given a function $g$ which has derivative $g'$ for all x $\in {R}$ and satisfying $g'(0)=2$ and $g(x+y)=e^yg(x)+e^xg(y)$ for all $x,y\in {R}$
Show that $g'(x)+g(x)-2e^x=0$

$\dfrac{g(x+y)}{e^{x+y}}=\dfrac{g(x)}{e^{x}}+\dfrac{g(y)}{e^{y}}$
Putting $x=0$,
$g'(y)=2e^y+g(x)$
Also putting $y=0$,we get,
$0=e^xg(0)\implies g(0)=0$
I had a strong hunch that $g(x)=e^x-e^{-x}$ but it does not satisfy $g(x+y)=e^yg(x)+e^xg(y)$
Please help.
 A: Let $h(x)=\frac{g(x)}{e^x}$. Then, $h'(x)=\frac{g'(x)e^x-g(x)e^x}{e^{2x}}$.
Note that you wrote $h(x+y)=h(x)+h(y)$.
Then, $h'(x)=\lim_{\epsilon\to 0} \frac{h(x+\epsilon)-h(x)}{\epsilon}=\lim_{\epsilon\to 0}\frac{h(\epsilon)}{\epsilon}=h'(0)=2$ whatever $x\in\mathbb{R}$ since you noted that $h(0)=g(0)=0$.
then $h'(x)=\frac{g'(x)e^x-g(x)e^x}{e^{2x}}$ becomes $2e^x+g(x)=g'(x)$. Any chance that sign was the other way?
A: $$g(x+y) = e^y g(x) + e^x g(y)$$
Differentiating w.r.t. y
$$g'(x+y) = e^y g(x) + e^x g'(y)$$
Now put $y=0$
$$g'(x) = e^0 g(x) + e^x g'(0)\implies g'(x) - g(x) - 2e^x = 0$$
A: As noted in question and one other answer, with $h(x)=e^{-x}g(x)$ you get $h$ differentiable at $x=0$ and $h(x+y)=h(x)+h(y)$. This is one of Cauchy's fundamental functional equations with solution $h(x)=ax$. Now insert to $g(x)=axe^x$ and compare the derivatives $g'(x)=a(1+x)e^x$ at $x=0$, $2=g'(0)=a$, to get the unique solution.

Setting $x=0$ in the original equation gives
$$
g(y)=e^yg(0)+g(y)\implies g(0)=0
$$
Computing the $x$-derivative and then setting $x=0$ results in
$$
g'(x+y)=e^yg'(x)+e^xg(y)\implies
g'(y)=e^yg'(0)+g(y)\implies g'(y)-g(y)-2e^y=0
$$
which has one sign different than the ODE that you obtained.
A: As pointed out in other answers/comments, if $g'(x)\color{red}{-}g(x)-2e^x=0, g'(0)=2$, then:
$$g(x)=2xe^x \Rightarrow g(x+y)=e^yg(x)+e^xg(y).$$
