Einige Fourierreihen

Achtung: Die entstehenden Fehler sind zum Studium gedacht!

1

Remove["Global`*"]

f[t_] := 
        t  /; (-Pi/2  ≤   t  &&  
              t  ≤  Pi/2);

    f[1]

f[t_] := 
        Pi - t  /; (Pi/2  <   t  &&  
              t  ≤  3 Pi/2);

Plot[f[t], {t, -Pi/2, 3  Pi/2}];

b[k_] := 
      1/Pi Integrate[f[t] Sin[k t], {t, -Pi/2, 3  Pi/2}]

Table[b[k], {k, 1, 10}]

Table[b[k], {k, 1, 10}] // N // Chop

b[k_] := 
      1/Pi (Integrate[t Sin[k t], {t, -Pi/2, Pi/2}] + 
            Integrate[(Pi - t) Sin[k t], {t, Pi/2, 
                3  Pi/2}])

ta = Table[b[k], {k, 1, 20}]

b[k_] := 
      1/Pi (NIntegrate[t Sin[k t], {t, -Pi/2, Pi/2}] + 
            NIntegrate[(Pi - t) Sin[k t], {t, Pi/2, 
                3  Pi/2}])

ta = Table[b[k], {k, 1, 20}] // N // Chop

fF[t_] := Sum[ta[[k]] Sin[k t], {k, 1, 20}]

fF[t]

Plot[{fF[t]}, {t, -Pi/2, 3  Pi/2}];

Plot[{f[t], fF[t]}, {t, -Pi/2, 3  Pi/2}];

Plot[{fF[t]}, {t, -Pi/2, 12  Pi/2}];

f[t_] := f[t - 2 Pi];

Plot[f[t], {t, -Pi/2, 12  Pi/2}];

b[k_] := 
      1/Pi Integrate[f[t] Sin[k t], {t, -Pi/2, 3  Pi/2}]

Table[b[k], {k, 1, 10}]

b[k_] := 
      1/Pi NIntegrate[f[t] Sin[k t], {t, -Pi/2, 3  Pi/2}]

Table[b[k], {k, 1, 10}]

2

Remove["Global`*"]

f[t_] := 
        0 /; (0  ≤   t  &&  
              t  <  Pi);

    f[1]

f[t_] := 
        1  /; (Pi  ≤    t  &&  
              t  <  2 Pi);
f[t_] := 
        0 /; (2 Pi  ≤   t  &&  
              t  < 3 Pi);

Plot[f[t], {t, 0, 2  Pi}];

a[k_] := 
      1/Pi NIntegrate[f[t] Cos[k t], {t, 0, 2  Pi}] // Chop

Table[a[k], {k, 1, 10}]

b[k_] := 
      1/Pi Integrate[f[t] Sin[k t], {t, 0, 2  Pi}] // Chop

Table[b[k], {k, 1, 10}]

Table[b[k], {k, 1, 10}] // N // Chop

1/Pi (Integrate[Sin[k t], {t, Pi, 2  Pi}])

b[k_] := 1/Pi (Integrate[Sin[k t], {t, Pi, 2  Pi}])

ta = Table[b[k], {k, 1, 20}]

N[%]

ta = Table[b[k], {k, 1, 20}] // N // Chop

fF[t_] := +0.5 + Sum[ta[[k]] Sin[k t], {k, 1, 20}]

fF[t]

Plot[{fF[t]}, {t, 0, 2  Pi}];

Plot[{f[t], fF[t]}, {t, 0, 2  Pi}];

Plot[{fF[t]}, {t, 0, 6  Pi}];

f[t_] := f[t - 2 Pi];

Plot[f[t], {t, 0, 6 Pi}];

3

Remove["Global`*"]

f[t_] := 
          Sqrt[t^2] /; (-Pi  ≤   t  &&  
                t  ≤   Pi);;

    f[1]

Plot[f[t], {t, -Pi, Pi}];

a[0] = 1/Pi Integrate[f[t], {t, -Pi, Pi}]

a[k_] := 1/Pi Integrate[f[t] Cos[k t], {t, -Pi, Pi}]

ta = Table[a[k], {k, 1, 10}]

Table[a[k], {k, 0, 10}] // N // Chop

b[k_] := 1/Pi Integrate[f[t] Sin[k t], {t, -Pi, Pi}]

Table[b[k], {k, 1, 10}]

fF[t_] := a[0]/2 + Sum[ta[[k]] Cos[k t], {k, 1, 10}]

fF[t]

Plot[Evaluate[fF[t]], {t, -Pi, Pi}];

Plot[Evaluate[{f[t], fF[t]}], {t, -Pi, Pi}];

Plot[Evaluate[fF[t]], {t, -Pi, 6  Pi}];

f[t_] := f[t - 2 Pi];

Plot[f[t], {t, 0, 6 Pi}];

4 Mit Hilfe eines Moduls

Remove["Global`*"]

Handhabung einer Funktion inklusive der Variablen innerhalb eines Moduls

ser[f_, s_] := 
        Module[{w, m}, 
w[m_] := Function[v[#]][m];  
          Print[w[s]];
];
v[t_] := Cos[t]; ser[v[t], xX]

Ein Modul für Fourierreihen mit einem Beispiel

Remove["Global`*"];

\(\(four[fkt_, var_, perT_, start0Int_, n_, druck_] := 
        Module[{fktInt, tInt, nInt, 
            znInt}, 

Print[" "]; \ 
          Print["Output:"]; \ 
          Print[" "]; 

ω\  = \ 2\ Pi/perT; \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ If[
            druck == 
              1, \ \ Print["ω = ", ω], " "];; 

fktInt[tInt_] := \(Function[fkt[#]]\)[
              tInt]; \ \ \ If[druck == 1, \ 
            Print["Funktion[", var, "]  = ", 
              fktInt[var]], " "]; 

a[
              0] = 2/T\ Integrate[
                fktInt[var], {var, start0Int, 
                  start0Int + perT}]; \ \ \ \ \ If[druck == 1, \ 
            Print["a[0] = ", 
              a[0]], " "]; 

a[k_] := 
            2/T\ Integrate[
                Cos[k\ ω\ var]\ \ fktInt[var], {var, start0Int, 
                  start0Int + perT}]; \ \ \ \ \ If[druck == 1, \ 
            Print["a[k] = ", 
              a[k]], " "]; 

b[k_] := 
            2/T\ Integrate[
                Sin[k\ ω\ var]\ \ fktInt[var], {var, start0Int, 
                  start0Int + perT}]; \ \ \ \ \ If[druck == 1, \ 
            Print["b[k] = ", 
              b[k]], " "]; 

c[k_] := 
            1/T\ Integrate[
                fktInt[var]\ \ E^\((\(-I\)\ k\ ω\ var)\), {var, 
                  start0Int, start0Int + perT}]; \ \ If[druck == 1, \ 
            Print["c[k] = ", 
              c[k]], " "]; 

ff[
              tInt_, znInt_] := 
            a[0]/2 + 
              Sum[a[nInt]\ Cos[nInt\ ω\ tInt] + 
                  b[nInt]\ Sin[nInt\ ω\ tInt], {nInt, 1, 
                  znInt}]; 
\ 
          If[druck == 1, \ 
            Print["Fourierreihe[", var, ", ", n, "]  = ", 
              ff[var, n]], " "]; 

ff[
              tInt_] := a[0]/2 + 
              Sum[a[nInt]\ Cos[nInt\ ω\ tInt] + 
                  b[nInt]\ Sin[nInt\ ω\ tInt], {nInt, 1, 
                  Infinity}]; 
\ 
          If[druck == 1, \ 
            Print["Unendliche Fourierreihe[", var, "]  = ", 
              ff[var]], " "]; 

ffExp[
              tInt_] := ExpToTrig[
              a[0]/2 + 
                Sum[a[nInt]\ Cos[nInt\ ω\ tInt] + 
                    b[nInt]\ Sin[nInt\ ω\ tInt], {nInt, 1, 
                    Infinity}]]; 
\ 
          If[druck == 1, \ 
            Print["Unendliche Fourierreihe komplex[", var, "]  = ", 
              ffExp[var]], " "]; 

ffKomplexTrig[tInt_, znInt_] := 
            ExpToTrig[
              Sum[c[nInt]\ E^\((I\ nInt\ ω\ \ tInt)\), {nInt, \(-znInt\), znInt}]]; 
\ 
          If[druck == 1, \ 
            Print["Komplexe Fourierreihe wieder trigonometrisch[", 
              var, ", ", n, "]  = ", 
              ffKomplexTrig[var, 
                n]], " "]; 

ffKomplexExp[tInt_, znInt_] := 
            TrigToExp[
              Sum[c[nInt]\ E^\((I\ nInt\ ω\ \ tInt)\), {nInt, \(-znInt\), znInt}]]; 
\ 
          If[druck == 1, \ 
            Print["Komplexe Fourierreihe[", var, ", ", 
              n, "]  = ", 
              ffKomplexExp[var, 
                n]], " "]; 

ffKomplex[tInt_] := 
            Sum[c[nInt]\ E^\((I\ nInt\ ω\ \ tInt)\), {nInt, \(-Infinity\), Infinity}]; 
\ 
          If[druck == 1, \ 
            Print["Komplexe Fourierreihe[", var, "]  = ", 
              ffKomplex[
                var]], " "]; 

Print["Plot"]; 
Plot[
            Evaluate[{fktInt[var], ff[var, n]}], {var, start0Int, 
              start0Int + perT}];
];\)\)

f[t_] := 
        t;

    T = 2 Pi;

    t0 = -Pi;

    four[f, t, T, t0, 6, 1]

5 Anwendung von eingebauten Funktionen

Remove["Global`*"]

?*Four*

<< Calculus`FourierTransform`;

?*Four*

Beispiel 1

f[t_] := t;

FourierTrigSeries[f[t], t, 10]

FourierSinCoefficient[f[t], t, 10]

FourierCosCoefficient[f[t], t, 10]

FourierSeries[f[t], t, 10]

Plot[
        Evaluate[FourierTrigSeries[f[t], t, 10]], {t, -1, 
          3}];

Beispiel 2

Remove["Global`*"]

<< Calculus`FourierTransform`;

f[t_] := t;

f1[u_] = 
        2  Pi FourierTrigSeries[f[t], t, 10] /. t -> u/(2  Pi) // 
          Expand;
Print[f1[u]];

f2[u_] = 
      2  Pi (FourierSeries[f[t], t, 10] /. t -> u/(2  Pi)) // 
        Expand

Plot[f1[u], {u, -0.3, 8}];

Plot[Evaluate[Re[f2[u]]], {u, -0.3, 8}];