\documentclass[a4paper]{article}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}

\newcommand{\N}{\ensuremath{\mathbb{N}}}

\begin{document}
Exercises for chapter 2.1
	
MVE030 Fourieranalys  

MVE290 Fouriermetoder 


	
\textbf{2.1:4} This is the ReLU function, which is very important in Machine Learning. In a neural network, the activation function is responsible for transforming the summed weighted input from the node into the activation of the node or output for that input. The ReLU is useful because it is fast to compute and therefore ``easy to teach''.
%
\begin{equation}\label{eq:4}
f(\theta) = 
\begin{cases}
0, & \theta\in(-\pi,0)\\
\theta, & \theta\in(0,\pi)
\end{cases}
\end{equation}
%
Also, $f(0)=0$. 
\begin{equation}\label{eq:4.1}
2\pi c_n = \int_{-\pi}^\pi f(\theta)e^{-in\theta} d\theta = \int_0^\pi \theta e^{-in\theta} d\theta 
\end{equation}
%
If $n=0$, this equals $\pi^2/2$, and if $n\neq 0$ then we can use integration by parts. The right hand side of~(\ref{eq:4.1}) equals
%
\[
  \frac{1}{-in}\int_0^\pi\theta\frac{d}{d\theta} e^{-in\theta} d\theta= \frac{1}{-in}\left[\theta e^{-in\theta}\right]_0^\pi - \int_0^\pi \frac{e^{-in\theta}}{-in} d\theta = \frac{\pi e^{-in\pi}}{-in}+\frac{e^{-in\pi}-1}{n^2}
\]
%
So for odd $n$, $2\pi c_n=-i\pi/n-2/n^2$ (because $e^\pi=e^{3\pi}=-1$ and so on) and for even $n$, $2\pi c_n=i\pi/n$. This yields
%
\begin{align}
  f(\theta) & = \sum_{n\in \N} c_n e^{in\theta}\\
  & = \frac{\pi}{4}+\sum_{n\in \N} \frac{-1}{\pi(2n-1)^2}e^{i(2n-1)\theta} + \sum_{n\in \N} \left(\frac{i/2e^{2in\theta}}{2n}-\frac{i/2e^{i(2n-1)\theta}}{(2n-1)}\right)\\
  & = \frac{\pi}{4}+\sum_{n\in \N} \frac{-1}{\pi(2n-1)^2}e^{i(2n-1)\theta} - \sum_{n\in \N} \frac{i/2}{n}(-1)^{n+1}e^{in\theta}
\end{align}
%
And
\[
\sum_{n\in \N} \frac{-1}{(2n-1)^2}e^{i(2n-1)\theta} = -\sum_1^\infty\frac{e^{i(2n-1)\theta}+e^{-i(2n-1)\theta}}{(2n-1)^2}  = -2\sum_1^\infty \frac{\cos(2n-1)\theta}{(2n-1)^2}
\]
and
\[
\sum_{n\in \N}\frac{(-1)^{n+1}}{n}e^{in\theta} = \sum_1^\infty \frac{(-1)^{n+1}}{n}\left(e^{in\theta}-e^{-in\theta}\right)=2i\sum_1^\infty \frac{(-1)^{n+1}}{n}\sin n\theta
\]
Thus
\[
f(\theta)=\frac{\pi}{4}-\frac{2}{\pi}\sum_{n=1}^\infty \frac{1}{\pi(2n-1)^2}e^{i(2n-1)\theta} + \sum_{n=1}^\infty \frac{(-1)^{n+1}}{n}\sin n\theta
\]
Here are some questions for you to investigate: Why would anyone want to use Fourier methods in Machine Learning? The Fourier series seems much more difficult to compute numerically than $f(\theta)$, but can we truncate the sums without too much loss of accuracy?

 
\textbf{2.1:8}
\textbf{2.1:14}
\textbf{2.1:16}
\end{document}