The Fourier transformation of $\cos(x)$ the Fourier transformation of $\cos(x)$,
\begin{equation}
f(k)=\int_{-\infty}^{+\infty}\cos(x)e^{ikx}dx
\end{equation}
$1$. on one hand we have
\begin{equation}
\begin{aligned}
f(k)=&\int_{-\infty}^{+\infty}\cos(x)e^{ikx}dx\\
=&\int_{-\infty}^{+\infty}((e^{ix}+e^{-ix})/2)e^{ikx}dx\\
=&\frac{1}{2}(\delta(k+1)+\delta(k-1))
\end{aligned}
\end{equation}
$2$. on the other hand, we have
\begin{equation}
\begin{aligned}
f(k)=&\int_{-\infty}^{+\infty}\cos(x)e^{ikx}dx\\
=&\int_{-\infty}^{+\infty}(1-\frac{1}{2!}x^2+...)e^{ikx}dx\\
=&\delta(k)-\frac{1}{i^2 2!} \frac{d^{2}}{dk^2}\delta(k)+...
\end{aligned}
\end{equation}
with the fact
$$\int_{-\infty}^{+\infty}xe^{ikx}dx=\frac{1}{i}\frac{d}{dk}\int_{-\infty}^{+\infty}e^{ikx}dx=\frac{1}{i}\frac{d}{dk}\delta(k), $$
$$\int_{-\infty}^{+\infty}x^ne^{ikx}dx=\frac{1}{i^n}\frac{d^n}{dk^n}\int_{-\infty}^{+\infty}e^{ikx}dx=\frac{1}{i^n}\frac{d^n}{dk^n}\delta(k).$$
If we take $k=1$, eq. ($1$) gives me $\frac 1 2 \delta(0)$ , but eq. ($2$) gives me $0$, Where did I go wrong?
 A: Technically, what you have arrived at is not 100% wrong, but for a sign error. So if there is a domain for $f$ with radius of convergence greater than one about the origin, then we know that$$f(1) = f(0) + f'(0) + \frac12 f''(0) +\dots$$and similarly
$$f(-1) = f(0) - f'(0) + \frac12 f''(0) -\dots$$
hence
$$\frac{f(1)+f(-1)}2 = f(0) + \frac12 f''(0) +\dots,$$
and this induces an effective relation that on the right space of functions $f$, $$
\int_{\mathbb R}\mathrm dx\frac{\delta(x - 1) + \delta(x + 1)}2 f(x) 
=
\int_{\mathbb R}\mathrm dx\left[\delta(x) + \frac12 \delta''(x) +\dots\right] f(x) .$$
This space under the integral sign is in some ways the only sense in which the Dirac $\delta$-functions “exist” as functions; we say some limit or some expression is a Dirac $\delta$ when it acts the right way under an integral sign.
You asked this on the Physics Stack Exchange so I felt compelled to take for granted that in fact most of our physics applications concern this “right space of functions $f$,” but now that it has been migrated to the Mathematics Stack Exchange I feel compelled to add that this space of functions is not particularly “normal” for any mathematician to consider when defining a Dirac $\delta$. What you've got is wrong, it’s just not 100% wrong and has some limited applicability.
So basically you assumed that you could distribute the integral over all of this infinite series of terms, collapse each term into a $\delta$-derivative, and then sum over all the $\delta$-derivatives, this manipulation is not 100% well-defined when you have these integrals that don’t actually converge and are being interpreted after-the-fact as existing in some $\int \mathrm dk~f(k)$ term to make them converge; in fact you are making an explicit assumption about this $f(k)$ in order to make this manipulation meaningful.
That assumption in turn is actually even more strong than $f$ just being, say, smooth along the real line; $1/(x^2 + 1)$ is an example of a function which is smooth along the real line but only has radius-of-convergence $1$ about the point $x=0.$ Mathematicians would actually go one further with a bump function, which you could center say at $x=1$ with width $1/2$ and then it and all of its derivatives are $0$ at $x=0$ but it is nonzero on the interval $(0.5, 3.5)$ and so one of these $\delta$-function expressions has a nonzero integral with it from a $\delta(x-1)$ term while the other $\delta$-function expression, which only picks out derivatives at zero, must operate on it to produce zero.
A: One would have the same issue with $\cos x$ as with $\mathrm{e}^{-\mathrm{i}x}$, so work with the latter. Then the crux of the matter is whether or not the sequence
$$\begin{align}
  f_{(-)}&:\,\mathbb{N}\to D(\mathbb{R}) &
  f_N&=\sum_{n=0}^{N-1}\tfrac{(-1)^n}{n!}\delta^{(n)}_0
\end{align}$$
converges to
$$\begin{align}
 f &:\, D(\mathbb{R}) &
 f &= \delta_1
\end{align}$$
in $D(\mathbb{R})$:
$$\lim_{N\to\infty}f_N \stackrel{?}{=} f\text{.}$$
In the original, "physics-y" notation, one would write
$$\lim_{N\to\infty}\sum_{n=0}^{N-1}\frac{(-1)^{n}}{n!}\delta^{(n)}(k)\stackrel{?}{=}\delta(k-1)\text{.}$$
This equality holds if and only if it is the case that for all test functions $\phi : C_{\mathrm{c}}^{\infty}(\mathbb{R})$ one has
$$\lim_{N\to\infty}\langle f_N,\phi\rangle \stackrel{?}{=} \langle f,\phi\rangle\text{,}$$
i.e., iff
$$
\lim_{N\to\infty} \sum_{n=0}^{N-1}\frac{\phi^{(n)}(0)}{n!}\stackrel{?}{=}\phi(1)\text{.}
$$
But this last equality does not hold for all test functions, because smooth functions need not be real-analytic. For example,
$$\begin{align}
\psi &:\, C_{\mathrm{c}}^{\infty}(\mathbb{R}) &
\psi(k) &= \exp\left(1-\frac{1}{\max(k,0)\max(2-k,0)}\right)
\end{align}$$
is smooth, vanishes outside of $[0,2]$, and satisfies
$$\begin{align}
\forall_{N:\mathbb{N}}\psi^{(N)}(0)&= 0 &
\psi(1) &= 1
\end{align}$$
so that
$$
\lim_{N\to\infty} \sum_{n=0}^{N-1}\frac{\psi^{(n)}(0)}{n!}=0 \neq 1 =\psi(1)\text{.}
$$
