First off, I have created the following Fourier series for the below equation/condition:
$$f(t) = \begin{cases} 0, & 0<t<1 \\ 1, & 1<t<2 \end{cases} $$
My Fourier Equation for the Above $f(t)$:
$$f(t) = \frac{1}{2} + \sum_{n=1}^{\infty} \frac{sin(2 \pi n)}{\pi n} cos(n \pi t) + \sum_{n=1}^{\infty} \frac{(-1)^n - cos(2\pi n)}{\pi n} sin(n \pi t)$$
In an earlier post (i.e. Limiting the Domain of a Function), I have asked the community how can I properly plot the $f(t)$ piecewise functions with the given constraints. And, the community here recommended using piecewise
to solve the problem. While that worked great, I have a hard time adding any additional argument(s) to the piecewise
command.
Beyond that, trying to plot the Fourier series doesn't seem to be working quite well when the plot does not show anything. Below is my code:
f[n_]=( 1/2) + (((sin(2*n*pi))/(pi*n))*(cos(n*pi*t)))+((((-1)^n - cos(2*pi*n))/(pi*n))*(sin(n*pi*t)))
f[t_, Nmax_]:= Sum[f[n], {n, 1, Nmax}]
Plot[{f[t, 2]}, [t, 0, 2.5}]
In short, my problem is as follows: 1. I can't find a way to graph my Fourier Series and $f(t)$ piecewise functions on the same graph. 2. I can't seem to plot out the Fourier Series for some unknown reason.
Any help would be greatly appreciated. Thank you!