Derive taylor series of $e^{\sin(x)}$ in two different ways

I need to find the Taylor series of $e^{\sin(x)}$ up to $x^4$ in two different ways. First I derived it by calculating the derivatives of the function, and I found the answer $P_4(x) = 1+x+ \frac{x^2}{2} - \frac{x^4}{8}$. Now I need to use the Taylor series of $e^y$ and plug in the Taylor series of $\sin(x)$ to find an answer. After that I need to draw a conclusion. So I know the Taylor series of $e^y$ up to $y^4$ looks like $P_4(y) = 1 + y + \frac{y^2}{2} + \frac{y^3}{6} + \frac{y^4}{24}$ and the Taylor series of $\sin(x)$ up to $x^4$ looks like $P_4(x) = x - \frac{x^3}{6}$. I substituted the Taylor series of $\sin(x)$ into the $y$ variable of the Taylor series of $e^y$, but it doesn't give me the same answer as the answer I got by using the first four derivates of $e^{\sin(x)}$. Am I doing anything wrong?


Solution 1:

After computing$$1+\left(x-\frac{x^3}6\right)+\frac12\left(x-\frac{x^3}6\right)^2+\frac16\left(x-\frac{x^3}6\right)^3+\frac1{24}\left(x-\frac{x^3}6\right)^4$$you must eliminate the monomials whose degree is greater than $4$. And then you will get the same answer as before.

Solution 2:

Let $e^{\sin x}=\sum_{r=0}^\infty a_rx^r$

$\sin x=\ln(\sum_{r=0}^\infty a_rx^r)$

Differentiate both sides with respect to $x$

$\cos x(\sum_{r=0}^\infty a_rx^r)=\sum_{r=1}^\infty a_rrx^{r-1}$

Expand $\cos x$ and compare the constant and the coefficients of $x,x^2,x^3,x^4$ to find $a_r,0\le r\le4$