(* Student Name *)
(* Date *)
(* MITES Physics III: Intro to Oscillations and Waves *)
(* Understanding Fourier Series*)

(a)

(* Run the code below *)
Plot[ Sin[x],{x,0,2Pi}, PlotStyle -> Orange] (*Plot Sin function *)

(* The code below shows how Taylor Series can be used to approximate Trig functions. Run the code, then annotate each line explaining its meaning in the overall code *)

a[n_] := Sin[n Pi/2]/n!; 

f[n_,x_] := x^(n); 

y[x_,nf_]:=Sum[a[n]f[n,x], {n,0, nf}] 

Plot[y[x,100],{x,0,2Pi}]

(b)

(* Run the code below *)

Plot[Piecewise[{{x,x <1/2},{1-x,x>1/2}}],{x,0,1}, PlotStyle -> Orange]

(* Modify the first four lines of the Taylor Series code to compute and plot the Fourier Series approximation of the above function *)

(* Create three plots: 1) the first five non-zero terms in the Fourier Series; 2) the first 10 non-zero terms in the Fourier Series; 3) the first 25 non-zero terms in the Fourier Series*)