Euler-Mascheroni Constant in the Cosine Integral? I came across this integral when doing calculus homework (Integration by parts) $$\int \frac{\cos x}x \, dx $$
It turned out in the end that there was a typo in the original question and this integral is not actually necessary, but I was curious and decided to attempt it. My first step was to turn cosine into its series and divide by X to leave a polynomial (series) that is easy to integrate. After doing so, I was left with this  but without the symbol on the left. After some googling, I discovered that the actual integral is what I thought it was + the Euler-Mascheroni constant. Can anyone tell me why the constant is there?
For backround information, I am currently a senior in High School taking Calculus. So I don't have extensive knowledge of more complicated methods like linear or abstact algebra.
 A: $\newcommand{\ci}{\operatorname{Ci}}\newcommand{\cin}{\operatorname{Cin}}\newcommand{\d}{\,\mathrm{d}}$You want to know why: $$\int_z^\infty\frac{\cos(t)}{t}\,\mathrm{d}t=-\gamma-\ln z-\sum_{n\ge1}^\infty(-1)^n\frac{z^{2n}}{2n\cdot(2n)!}=-\gamma-\ln z+\int_0^z\frac{1-\cos(t)}{t}\,\mathrm{d}t$$
This is not at all obvious. I do have a proof in my notes I took from two years ago, I'll share it here. I probably found this proof somewhere obvious but a quick explore with Approach0 hasn't shown any duplicates.
Let's define: $$\begin{align}\cin(x)&=\int_0^x\frac{1-\cos t}{t}\d t\\\ci(x)&=-\int_x^\infty\frac{\cos t}{t}\d t\end{align}$$For positive real $x$. We want to show: $$\cin(x)+\ci(x)=\gamma+\ln x$$For all $x>0$. As a corollary (this was the result I originally had wanted to research): $$\lim_{x\to0^+}\ci(x)-\ln x=\gamma$$Since $\cin(x)\in o(x)$ as $x\to0^+$.
Let $n\in\Bbb N$ be arbitrary and $t=2\pi n u$ in the integrand of $\cin$: $$\begin{align}\cin(\pi n)&=\int_0^{1/2}\frac{1-\cos2\pi n u}{u}\d u\\&=\pi\int_0^{1/2}\frac{1-\cos2\pi nu}{\sin\pi u}\d u+\int_0^{1/2}f(u)\d u-\int_0^{1/2}f(u)\cdot\cos2\pi n u\d u\\&=2\pi\sum_{k=1}^n\int_0^{1/2}\sin((2k-1)\pi u)\d u+\left[\ln\left(u\cot\left(\frac{\pi}{2}u\right)\right)\right]_0^{1/2}\\&\quad\quad-\int_0^{1/2}f(u)\cos2\pi nu\d u\\&=2\sum_{k=1}^n\frac{1}{2k-1}+\ln\pi-2\ln2-\int_0^{1/2}f(u)\cos2\pi nu\d u\end{align}$$Where: $$f(u):=\begin{cases}0&u=0\\u^{-1}-\pi\csc\pi u&u>0\end{cases}$$Is a continuous real function, and we used: $$\begin{align}2\sum_{k=1}^n\sin((2k-1)\pi u)&=2\Im\left[e^{-i\pi u}\sum_{k=1}^ne^{2\pi i ku}\right]\\&=2\Im\left[e^{i\pi u}\cdot\frac{e^{2\pi i nu}-1}{e^{2\pi i u-1}}\right]\\&=2\Im\left[e^{\pi inu}\cdot\frac{2i}{e^{\pi i u}-e^{-\pi i u}}\cdot\frac{e^{\pi i nu}-e^{-\pi i nu}}{2i}\right]\\&=2\Im\left[e^{\pi i nu}\frac{\sin(\pi nu)}{\sin(\pi u)}\right]\\&=\frac{2\sin^2(\pi nu)}{\sin(\pi u)}\\&=\frac{1-\cos(2\pi nu)}{\sin(\pi u)}\end{align}$$For all suitable values of $u$.
Now define: $$\begin{align}c_n&:=\cin(\pi n)-\ln(\pi n)=\int_0^1\frac{1-\cos t}{t}\d t+\int_1^{\pi n}\frac{1-\cos t}{t}\d t-\ln(\pi n)\\&=\cin(1)-\int_1^{\pi n}\frac{\cos t}{t}\d t\end{align}$$For all $n\in\Bbb N$.
It follows that $\lim_{n\to\infty}c_n=\cin(1)+\ci(1)$. But: $$c_n=2\sum_{k=1}^n\frac{1}{2k-1}-\ln n-2\ln2-\int_0^{1/2}f(u)\cos(2\pi nu)\d u$$
Using: $$\lim_{n\to\infty}2\sum_{k=1}^{4n}\frac{1}{k}-2\ln4n=2\gamma,\,\lim_{n\to\infty}\sum_{k=1}^{2n}\frac{1}{k}-\ln2n=\gamma$$A subtraction gives: $$\lim_{n\to\infty}2\sum_{k=1}^{2n}\frac{1}{2k-1}-\ln n-3\ln 2=\gamma,\,\lim_{n\to\infty}2\sum_{k=1}^n\frac{1}{2k-1}-\ln n=\gamma+2\ln 2$$
The above used the definition of $\gamma$ as the limiting difference between the natural logarithm and the harmonic numbers, some sum manipulations, and the results: $$\begin{align}\lim_{n\to\infty}\sum_{k=n}^{2n}\frac{2}{2k-1}&=\lim_{n\to\infty}\sum_{k=n}^{2n}\frac{2}{2k}\\&=\lim_{n\to\infty}\frac{1}{n}\sum_{k=n}^{2n}\frac{1}{k/n}\\&=\lim_{n\to\infty}\frac{1}{n}\sum_{m=0}^n\frac{1}{1+\frac{m}{n}}\\&=\int_0^1\frac{1}{1+x}\d x\\&=\ln2\\2\sum_{k=1}^{4n}\frac{1}{k}-\sum_{k=1}^{2n}\frac{1}{k}&=2\sum_{k=1}^{2n}\frac{1}{2k-1}\end{align}$$
By the Riemann-Lebesgue lemma (or just integrating by parts) we see: $$\lim_{n\to\infty}\int_0^{1/2}f(u)\cos2\pi n u\d u=0$$Hence: $$\lim_{n\to\infty}c_n=\gamma$$
That is: $$\begin{align}\gamma&=\lim_{n\to\infty}c_n\\&=\cin(1)+\ci(1)\\&=\int_0^x\frac{1-\cos t}{t}\d t+\int_x^1\frac{1-\cos t}{t}\d t-\int_1^x\frac{\cos t}{t}\d t-\int_x^\infty\frac{\cos t}{t}\d t\\&=-\ln x+\cin(x)+\ci(x)\end{align}$$
Finally concluding: $$\cin(x)+\ci(x)=\gamma+\ln x$$For all real $x>0$, as was to be shown. $\blacksquare$
