Calculating a Taylor Polynomial of a mystery function I need to calculate a taylor polynomial for a function $f:\mathbb{R} \to \mathbb{R}$ where we know the following
$$f\text{ }''(x)+f(x)=e^{-x} \text{ } \forall x$$ $$f(0)=0$$ $$f\text{ }'(0)=2$$
How would I even start?
 A: The Frobenius method for solving differential equations is easily done: assume an ansatz
$$f(x)=c_0+\sum_{k=1}^\infty c_k x^k$$
and you have the derivatives
$$\begin{align*}
f^\prime(x)&=\sum_{k=1}^\infty k c_k x^{k-1}=c_1+\sum_{k=1}^\infty (k+1)c_{k+1} x^k\\
f^{\prime\prime}(x)&=\sum_{k=1}^\infty k(k+1)c_{k+1} x^{k-1}
\end{align*}$$
From these, you have $c_0=0$ and $c_1=2$ (why?); a relation for the other $c_k$ can be derived by comparing the series coefficients of $f(x)+f^{\prime\prime}(x)$ with the coefficients of $\exp(-x)$.
A: We have the following
$$f''(x) + f(x) = e^{-x}$$
and $f(0) = 0$, $f'(0) = 2$.
And thus we need to find $f^{(n)}(0)$ to construct the Taylor series.
Note that we already have two values and can find $f''(0)$ since
$$f''(0) + f(0) = e^{-0}$$
$$f''(0) +0 = 1$$
$$f''(0) = 1$$
So now we differentiate the original equation and get:
$$f'''(x) + f'(x) = -e^{-x}$$
But since we know $f'(0) = 2$, then
$$f'''(0) + f'(0) = -e^{-0}$$
$$f'''(0) + 2 = -1$$
$$f'''(0) = -3$$
And we have our third value. Differentiating one more time gives
$$f^{IV}(x) + f''(x) = e^{-x}$$
So again we have
$$f^{IV}(0) + f''(0) =1$$
$$f^{IV}(0) + 1 =1$$
$$f^{IV}(0) =0$$
Using this twice more you'll get
$$f^{V}(0) =2$$
$$f^{VI}(0) =1$$
$$f^{VII}(0) =-3$$
In general the equation is saying that
$$f^{(2n+2)}(0) + f^{(2n)}(0) = 1$$
$$f^{(2n+1)}(0) + f^{(2n-1)}(0) = -1$$
which will allow you to get all values.
A little summary of the already known values:
$f(0) = 0$ 
$f'(0) = 2$ 
$f''(0) = 1$ 
$f'''(0) = -3$ 
$f^{IV}(0) = 0$ 
$f^{V}(0) = 2$ 
$f^{VI}(0) = 1$ 
$f^{VII}(0) = -3$
Do you see a pattern? 
A: Hint: Assume that
$$
f(x)=\sum\limits_{n\geqslant0}a_n\frac{x^n}{n!},\qquad g(x)=\sum\limits_{n\geqslant0}b_n\frac{x^n}{n!},
$$
and that $g=f''+f$.
Then
$$ 
f''(x)=\sum\limits_{n\geqslant0}a_{n+2}\frac{x^n}{n!},
$$
hence, for every $n\geqslant0$, $b_n$ is...
To do: Identify $b_n$ for every $n\geqslant0$ and translate the initial conditions on $f$ in terms of $a_0$ and $a_1$.
A: This is a 2nd order linear non-homogeneous ODE with solution $f(x)=\frac{-1}{2}\cos x + \frac{5}{2} \sin x + \frac{1}{2} e^{-x}$. With the Taylor series for $\sin(x),\cos(x),$ and $e^{-x}$ in hand, you should be able to compute the series for $f$ straightforwardly.
