x (E^x + 1) Log[x] - x E^x + x^2 + x + 1 /.
Log[x] -> u - x //
Collect[#, u, Factor] /. u -> Log[x] + x &
(* -((1 + x) (-1 + E^x x)) + (1 + E^x) x (x + Log[x]) *)
If I didn’t know the desired form, I’d probably investigate by hand, unless I knew from the original problem why one of the forms x + Log[x], x E^x - 1, E^x + 1, etc. was relevant to the problem. Then I would know to put things in terms of it, the way I put the above in terms of u = x + Log[x]. We were fortunate here that Log[x] appears in only one term in the desired form. To replicate the approach with u = x + 1, you’d have to figure out which of the x to substitute — and then make only that substitution. Not easy.
The functions
(−1+xe ^x
)
and
(x+lnx)
share the same implicit zeros when the domain is
x>0
. Rearranging the function into a form containing these two factors is conducive to analyzing the monotonicity and extremum of the function. This really relies on rich problem-solving experience and skills, and it is by no means easy. What is the principle behind your code that achieves this goal?
†Also suggested by Bill’s remark, “The functions (−1+xe ^x ) and (x+lnx) share the same implicit zeros…” That’s clear from the (-1+y) and Log[y] factors in each term of the first result.