I am trying to write my periodical function $f(t)$ in Fourier Series $$f(t)=\frac{a_0}{2}+\sum_{j=1}^Na_j\cos(j 2\pi t/\tau)+\sum_{j=1}^Nb_j\sin(j 2\pi t/\tau)$$
and I know that there is a really nice function FourierSeries
yet I have to explicitly find a formula for coefficients $a_j$ and $b_j$. So the theory says $$a_0=\frac 2\tau \int_{0}^\tau f(t)dt$$
$$a_j=\frac 2\tau \int_{0}^\tau f(t)\cos(j2\pi t/\tau)dt$$
$$b_j=\frac 2\tau \int_{0}^\tau f(t)\sin(j2\pi t/\tau)dt$$
and I did exactly that in my code
M1[t_] := M0 (1 + Sin[ω0 t]) /. ω0 -> 2 Pi/τ
M2[t_] :=
M0 (1 + Sin[ω0 t - (2 Pi)/3]) /. ω0 -> 2 Pi/τ
M3[t_] :=
M0 (1 + Sin[ω0 t - (4 Pi)/3]) /. ω0 -> 2 Pi/τ
moment[t_] =
Piecewise[{{Simplify[M2[t] + M3[t]],
0 <= t < τ/2}, {Simplify[M1[t] + M2[t] + M3[t]], τ/2 <=
t <= τ}}]
a0 = Simplify[
2/τ Integrate[moment[t], {t, 0, τ},
Assumptions -> {τ ∈ Reals, τ > 0}]]
aj[j_] = Assuming[j ∈ Integers,
Simplify[2/τ Integrate[
Cos[j 2 Pi t/τ] moment[t], {t, 0, τ},
Assumptions -> {τ ∈ Reals, τ > 0}]]]
bj[j_] = Assuming[j ∈ Integers,
Simplify[2/τ Integrate[
Sin[j 2 Pi t/τ] moment[t], {t, 0, τ},
Assumptions -> {τ ∈ Reals, τ > 0}]]]
momnetSeries[num_, t_] :=
a0/2 + Sum[aj[j] Cos[j 2 Pi t/τ ], {j, 1, num}] +
Sum[bj[j] Sin[j 2 Pi t/τ ], {j, 1, num}]
Note that a[j]
has unexpected and unwanted singularity$$a_j=\frac{\left((-1)^j+1\right) \text{M}_0}{\pi \left(j^2-1\right)}$$ at $j=1$ therefore the following code doesn't work
M0 = 102(*Nm*);
kn = 47*1000(*Nm/rad*);
Jn = 0.108 (*kg m^2*);
δ = 0.23;
obr = 4500;
τ = Pi/omega /. omega -> obr 2 Pi /60;
Plot[{momnetSeriest[100, t], moment[t]}, {t, 0, τ},
PlotRange -> All]
I wonder what is so badly wrong with my code or where does that singularity come from? I can't simply leave out $j=1$ from the Fourier Series formula.
moment
) is discontinuous? $\endgroup$