Taylor expansion of composite function 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).
 A: If you want to develop $f(g(x))$ around $x=a$, using the chain rule, you should get $$f(g(x))=f(g(a))+(x-a) g'(a) f'(g(a))+\frac{1}{2} (x-a)^2 \left(g'(a)^2 f''(g(a))+g''(a)
   f'(g(a))\right)+\frac{1}{6} (x-a)^3 \left(f'''(g(a)) g'(a)^3+3 g'(a) g''(a)
   f''(g(a))+g'''(a) f'(g(a))\right)+O\left((x-a)^4\right)$$ Using $g(x)=x^2$ and $a=1$, this would then give $$f(x^2)=f(1)+2 (x-1) f'(1)+(x-1)^2 \left(2 f''(1)+f'(1)\right)+(x-1)^3 \left(\frac{4}{3}
   f'''(1)+2 f''(1)\right)+O\left((x-1)^4\right)$$ just as @levap answered.
A: In your first method, you consider $x^2$ as a number and plug it into Taylor series of $f(u)$ around $u = 1$. Write this series as $\sum_{n=0}^{\infty} a_n (u - 1)^n$. In order to plug it into the series and really get $f(x^2)$, the Taylor series of $f$ around $u = 1$ needs to converge at $u = x^2$ to $f(x^2)$. Assuming this is indeed the case, you get a representation of the form
$$ f(x^2) = \sum_{n=0}^{\infty} a_n (x^2 - 1)^n $$
which is a representation of $f(x^2)$ as a series of function but not a power series / Taylor expansion which must be of the form $\sum_{n=0}^{\infty} b_n (x - 1)^n$. If you want to transform it into a power series expansion around $x = 1$, you can write each $(x^2 - 1)^n$ in the form $c_0 + c_1 (x - 1) + \dots + c_{2n} (x - 1)^{2n}$ and then rearrange terms (justifying appropriately) to get an expression of the correct form for $f(x^2)$. In your case,
$$ (x^2 - 1)^n = (x-1)^n(x + 1)^n = (x-1)^n ((x - 1) + 2)^n = \\
(x-1)^n \sum_{k=0}^n { n \choose k } (x-1)^k 2^{n-k} = \sum_{l = n}^{2n} {n \choose l - n} 2^{2n - l} (x - 1)^l $$
and so
$$ f(x^2) = \sum_{n = 0}^{\infty} a_n (x^2 - 1)^n = \sum_{n = 0}^{\infty} a_n \left( \sum_{l = n}^{2n} {n \choose l - n} 2^{2n - l} (x - 1)^l \right) = \sum_{n = 0}^{\infty} \left( \sum_{\frac{n}{2} \leq k \leq n} a_k {k \choose n - k}2^{2k - n}\right) (x - 1)^n =  \sum_{n = 0}^{\infty} \left( \sum_{\frac{n}{2} \leq k \leq n} \frac{f^{(k)}(1)}{(n-k)!(2k-n)!} 2^{2k - n}\right) (x - 1)^n =  \\
 f(1) + 2f'(1) (x - 1) + (f'(1) + 2 f''(1))(x-1)^2 + \dots $$
which is the same thing you get by computing the coefficients $\frac{1}{n!} (f(x^2))^{(n)}|_{x = 1}$ using the chain rule.
A: 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. 
A: Your first series is not a Taylor series: it is of the form $$a_0 + a_1 (x^2-1) + a_2 (x^2-1)^2 + a_3 (x^2-1)^3 + \ldots$$ while a Taylor series is of the form $$a_0 + a_1 (x-c) + a_2 (x-c)^2 + a_3 (x-c)^3 + \ldots$$  
