We can use the quotient rule, here, which states that, for y=f(x)/g(x)y=f(x)g(x),
(dy)/(dx)=(f'(x)g(x)-f(x)g'(x))/(g(x))^2
Thus, as f(x)=x and g(x)=2+e^x,
(dy)/(dx)=(1*(2+e^x)-x(e^x))/(2+e^x)^2=color(green)((2+e^x-xe^x)/(2+e^x)^2)
Now, we can rewrite this first derivative as a product: (2+e^x-xe^x)(2+e^x)^-2
Applying the product rule, which states that when y=f(x)g(x),
(dy)/(dx)=f'(x)g(x)+f(x)g'(x)
It'll be easier for us to find f'(x) and g'(x) before proceeding to the whole derivation, so we do not get lost.
f'(x)=0+e^x+color(red)(1*e^x+x*e^x), thus color(green)(f'(x)=2e^x+xe^x)
Note that the red part was the demanded chain rule for xe^x.
Now, g'(x) demands chain rule, which states that (dy)/(dx)=(dy)/(du)(du)/(dx).
Renaming u=2+e^x, we have g(u)=u^-2
So,
(dy)/(du)=-2u^-3 and (du)/(dx)=e^x
Aggregating them in a multiplication as stated by chain rule:
(dy)/(dx)=(-2u^-3)(e^x)=(-2(2+e^x)^-3)(e^x)
g'(x)=color(green)((-2(e^x))/(2+e^x)^3)
Now that we have f(x), f'(x), g(x) and g'(x), we can go to product rule:
(d^2y)/(dx^2)=(e^x+e^x+xe^x)(e^x+2)^-2+(2+e^x+xe^x)(-2e^x(e^x+2)^-3)
(d^2y)/(dx^2)=(2e^x+xe^x)/(e^x+2)^2+((2+e^x+xe^x)(-2e^x))/(e^x+2)^3
To operate this sum, we have that the lowest common denominator (l.c.d.) is (e^x+2)^3. Thus,
(d^2y)/(dx^2)=((e^x+2)(2e^x+xe^x)+(-2e^x)(2+e^x+xe^x))/(e^x+2)^3
Distributing the factors, we get the following, which allows us to operate some cancelling, as I will remark in collors:
(d^2y)/(dx^2)=(color(red)(2e^(2x))color(green)(+xe^(2x))+color(blue)(4e^x)+2xe^xcolor(blue)(-4e^x)color(red)(-2e^(2x))color(green)(-2)xe^(2x))/(e^x+2)^3
Final simplification:
(d^2y)/(dx^2)=(2xe^x-xe^(2x))/(e^x+2)^3=color(green)((e^x(2-e^x)x)/(e^x+2)^3)