expanding an equation , part of coordinate perturbation if I have $$x_0 = \cos t $$
and I need to substitute $$ t = \tau + \epsilon T_1(\tau) + \epsilon^2 T_2(\tau) + \cdots $$
How do I go about the substitution and expansion to then gather like powers of $\epsilon$?
I only need up to the powers of $\epsilon ^2$ 
 A: Use Taylor series theorem and collect the terms up the one needed. Remember
$$f(x+h)=f(x)+hf'(x)+h^2 f''(x)/2!+h^3 f'''(x)/3!+\cdots.$$
So here substitute the expression for $t$ and do all that algebra, just keep only the terms you need.
A: Remember that
$$
\cos w = 1 - \frac{w^2}{2}+\frac{w^4}{24}-\cdots
$$
So
\begin{align}
x_0 & = \cos t = \cos\left( \tau+\varepsilon T_1(\tau)+\varepsilon^2T_2(\tau)+\cdots \right) \\
& = 1 -\frac{\left( \tau+\varepsilon T_1(\tau)+\varepsilon^2T_2(\tau)+\cdots \right)^2}{2} + \frac{ \left( \tau+\varepsilon T_1(\tau)+\varepsilon^2T_2(\tau)+\cdots \right)^4 }{24} - \cdots \\
& = \underbrace{1-\frac{\tau^2}{2} + \frac{\tau^2}{24}-\cdots} - \frac{2\tau\varepsilon T_1(\tau) + ( \varepsilon T_1(\tau) )^2 + 2\tau\varepsilon^2 T_2(\tau)}{2} + \frac{4\tau^3\varepsilon T_1(\tau) + 6\tau^2(\varepsilon T_1(\tau))^2 + 2\tau\varepsilon^2 T_2(\tau)}{24} -\cdots
\end{align}
The first term above is $\cos\tau$, and I suppose that's hardly surprising.
The coefficient of $\varepsilon^1$ is
$$
-\tau T_1(\tau) + \frac{\tau^3T_1(\tau)}{6} - \frac{\tau^5\varepsilon T_1(\tau)}{120} + \cdots = -T_1(\tau)\sin\tau.
$$
again, not surprising, I suppose.
The pattern in the coefficients of $\varepsilon^2$ might be harder to untangle.  So let's recall Faà di Bruno's formula and get the second derivative of the composition of two functions:
$$
(f\circ g)''(\tau) = f'(g(\tau)) g''(\tau) + f''(g(\tau)) (g'(\tau))^2.
$$
This is
$$
\cos'(t) 2T_2(\tau) + \cos''(t) (T_1(\tau))^2 = -2T_2(\tau) \sin t -(T_1(\tau))^2\cos t.
$$
