How to think about $x e^x$. I'm probably overthinking this but...
Let $f:\mathcal{R}\rightarrow \mathcal{R}$ s.t. $f(x)=xe^x$ for $x\in \mathcal{R}$. 
This function is obviously well behaved and well defined for all values of $x\in\mathcal{R}$. Yet I can rewrite this function as 
$f^*:\mathcal{R}\rightarrow \mathcal{R}$ s.t. $f(x)=e^{\log x+ x}$ for $x\in \mathcal{R}$ but this is clearly not "well behaved" for values of $x\leq0$. 
What is going on here?
A bit more detail on my thought process:
I think the crux of the question comes down to what "well behaved" means. 
What I am obviously objecting to comes from an algorithmic way of thinking about functions if you first try to calculate $y=\log x + x$ and plug that into $e^y$ you run into trouble. In contrast, if you just consider the functional object as a whole you run into no problems... in that case, $e^{\log x + x}$ is just an unwieldy mathematical representation of a well-defined function. Still, I feel like there is something mathematically interesting going on here that I would like to learn more about.  What branch of math deals with this type of question?
Perhaps there is some theory that states something along the lines of the following: 
Let $g_1(x) = e^y$, $g_2(x,y) = xy$, $g_1^*(x) = \log x +x$, $g_2^*(y)=e^y$. While $f \equiv f^* \equiv g_2(g_1(x)) \equiv g_2^*(g_1^*(x))$, $(g_2\circ g_1)(x)\not\equiv (g_2^*\circ g_1^*)(x)$?
 A: The equality $x=e^{\log x}$ only holds on $(0,\infty)$. You should keep in mind that $\log$ is a bijection from $(0,\infty)$ onto $\mathbb R$ and that its inverse is the exponential map, which is a bijection from $\mathbb R$ onto $(0,\infty)$.
A: What is going on? 
Since you wrote $e^x$, you can see that $x$ can be any real number. But since you write $e^{\log(x)}$ you are doing a composition $g(x)=e^{x}\circ\log(x)$ and the domain of a composition doesn't match with the initials function.
$$\mbox{dom } g = \{x\in \mbox{dom } \log~  \colon~ \log(x)\in\mbox{ dom } e^x \}$$
A: You could look up the concept of a right inverse and left inverse. The logarithm has a right inverse, but no left inverse (in the real numbers). My class studied this topic in our functional analysis course, it's a concept in algebra, I believe.
A: The two functions aren't the same. In first case if $x < 0$ then there is no problem but in the second case you represent $x$ as a power of the positive constant $e$. It is obvious that exponent of a positive number can never be negative. So second function 'crashes' when $x<0$.
