TITLE: Taylor expansion of composite function
QUESTION [8 upvotes]: My confusion is slightly related to this question. Suppose we have two nice functions $f(x)$ and $g(x)$, how do we find Taylor series of $f(g(x))$?
To be more concrete, consider $f(x^2)$. In this case, we can regard it as $f(g(x))$ where $g(x) = x^2$. One way to find the Taylor series around $1$ is just
$$f(x^2)=f(1)+f'(1)(x^2-1)+\frac{1}{2}f''(1)(x^2 - 1)^2+\cdots$$
However, what if I do this?
$$f(x^2)=f(g(x))=f(1)+\color{blue}{\frac{d}{dg}f(g(x))\cdot\frac{d}{dx}g(x)\biggr|_{x=1}}(x-1)+\frac{1}{2}\frac{d^2}{d^2 x}f(g(x))\biggr|_{x=1}(x-1)^2+\cdots$$
This ends up like
$$f(x^2) = f(1)+2f'(1)(x-1)+\cdots$$
Which looks different from what you should get. I am confused because I thought both methods are valid and they should agree (although I've always been using the first one, regarding $x^2$ as a "number" instead of a function).

REPLY [2 votes]: Use Faa di Bruno's formula for the k-th derivative of a composite function. You can find the expression of the formula in internet.