Finding $f$ from the functional equation $f(x+y)=f(x) + f(y) + e^{x+y}(x+y)-xe^x-ye^y+2xy$

The question asks us to find the function $f(x)$ with the given information:

Let $f:\mathbb R \to \mathbb R$ such that $f'(0)=1$ and $f(x+y)=f(x) + f(y) + e^{x+y}(x+y)-xe^x-ye^y+2xy$ where $x,y \in\mathbb R$. Then determine $f(x)$.

Also, it will be great if someone could explain the general approach used in such questions.

Thanks in advance.


Put $x = y = 0$: $$ f(0) = 2f(0) $$ so $f(0) = 0$.

Next, differentiate the original equation with respect to $y$ alone: $$ f'(x + y) = f'(y) + e^{x+y} + (x+y)e^{x+y} - e^y - ye^y + 2x. $$ Put $y = 0$: $$ f'(x) = f'(0) + e^x + xe^x - 1 + 2x = e^x + xe^x + 2x $$ Therefore $$ f(x) = \int_0^x \left(e^z + ze^z + 2z\right) dz. $$


Rewrite the equation as $f(x+y)-f(x)-f(y)=e^{x+y}(x+y)-xe^x-ye^y-2xy$ then simply note that $f(x)=x e^x-x^2$ does the trick.