Darstellung von Taylor-Polynomen mit Mathematica

Ralf Schaper
Fb Mathematik / Informatik 
Universität Kassel 

Dieses Programm ist zu finden unter

www . mathematik . uni - kassel . de/~rascha/
          Taylorpolynome . nb

Needs[ "Graphics`Colors`" ];
Needs[ "Graphics`Graphics`" ];
$DefaultFont = {"Times", 12};
tF[x_]   := TraditionalForm[x];
tFHF[x_] := TraditionalForm[ HoldForm[x] ];
aT[x_]   := AbsoluteThickness[x];

Taylorentwicklung  der Sinusfunktion:

ts[x_, n_] := 
      Normal[ Series[Sin[u], {u, 0, n}] ] /. u -> x

g1 = 
        Plot[Sin[x], {x, 0, 5  π}, 
          Ticks -> {{{π/2, tFHF[π/2]}, {5 π, 
                  5  π}}, {-2, -1, 1, 2}}, 
          AspectRatio -> 
            0.4, 
PlotLabel -> "Taylorentwicklung von \
sin(x)", PlotStyle -> {Red, aT[2]}];

Do[
        Show[{g1, 
            Plot[Evaluate[Table[ts[x, n], {n, k}]], {x, 0, 5  π}, 
              PlotPoints -> 51, DisplayFunction -> Identity ], 
            g1},  PlotRange -> {-2.1, 2.1}, 
          DisplayFunction -> $DisplayFunction], {k, 36, 
          36}];

Bilder für eine Animation der Taylorentwicklung  der Sinusfunktion:
Die Zellen müssen zusätzlich gruppiert werden ( "Manual Grouping" im Menü Cell Grouping des Menüs Cell ; dort Group Cells aktivieren ) um die Animation laufen lassen zu können. Das geht nachdem die Zellen markiert sind mit  Ctrl Y .

Do[
        Show[{g1, 
            Plot[Evaluate[Table[ts[x, n], {n, k}]], {x, 0, 5  π}, 
              PlotPoints -> 51, DisplayFunction -> Identity ]},  
          PlotRange -> {-2.1, 2.1}, 
          DisplayFunction -> $DisplayFunction], {k, 2, 36, 
          2}];

In dieser Sequenz sind hier einige Bilder ausgelassen.

Taylorentwicklung  der Cosinusfunktion:

tc[x_, n_] := 
      Normal[ Series[Cos[u], {u, 0, n}] ] /. u -> x

g2 = 
        Plot[Cos[x], {x, 0, 5  π}, 
          Ticks -> {{{π/2, tFHF[π/2]}, {5 π, 
                  5  π}}, {-2, -1, 1, 2}}, 
          AspectRatio -> 
            0.4, 
PlotLabel -> "Taylorentwicklung von \
cos(x)", PlotStyle -> {Red, aT[2]}];

Do[
        Show[{g2, 
            Plot[Evaluate[Table[tc[x, n], {n, k}]], {x, 0, 5  π}, 
              PlotPoints -> 51, DisplayFunction -> Identity ], 
            g2},  PlotRange -> {-2.1, 2.1}, 
          DisplayFunction -> $DisplayFunction], {k, 36, 36, 
          2}];

Programm für eine Animation:

Do[
        Show[{g2, 
            Plot[Evaluate[Table[tc[x, n], {n, k}]], {x, 0, 5  π}, 
              PlotPoints -> 51, DisplayFunction -> Identity ], 
            g2},  PlotRange -> {-2.1, 2.1}, 
          DisplayFunction -> $DisplayFunction], {k, 2, 36, 
          2}];

Taylorentwicklung  der Exponentialfunktion:

tce[x_, n_] := 
      Normal[Series[Exp[u], {u, 0, n}]] /. u -> x

g4 = 
        Plot[Exp[x], {x, -4, E}, 
          Ticks -> {{-4, -3, -2, -1, 1, 
                2, {E, 
                  tFHF[E]}}, {1, {E, 
                  tFHF[E]}, 4, 6, 8, 10, 12, 
                14}}, 
PlotLabel -> "Taylorentwicklung \
von exp(x)", 
PlotStyle -> {Red, 
              aT[2]}];

Do[
        Show[{g4, 
            Plot[Evaluate[
                Table[tce[x, n], {n, k}]], {x, -4, E}, 
              PlotPoints -> 51, DisplayFunction -> Identity ], 
            g4},  PlotRange -> {-6, 16}, 
          DisplayFunction -> $DisplayFunction], {k, 12, 
          12}];

Do[
        Show[{g4, 
            Plot[Evaluate[
                Table[tce[x, n], {n, k}]], {x, -4, E}, 
              PlotPoints -> 51, DisplayFunction -> Identity ], 
            g4},  PlotRange -> {-6, 16}, 
          DisplayFunction -> $DisplayFunction], {k, 1, 
          12}];

Taylorentwicklung  der geometrischen Reihe:

tcgeo[x_, n_] := 
      Normal[Series[(1/(1 - u)), {u, 0, n}]] /. u -> x

g5 = 
        Plot[(1/(1 - x)), {x, -1.2, 
            0.95}, 
AspectRatio  -> 
            Automatic, 
PlotRange ->  {{-1.2, 
                1.2}, {-0.2, 
                3}}, 
Ticks -> {{-1, -0.5, 
                0.5, 1}, {1, 2, 3}}, 
          PlotStyle -> {Red, 
              aT[2]}, 
PlotLabel -> "Taylorentwicklung \
von 1/(1-x)\n"];

Do[
        Show[{g5, 
            Plot[Evaluate[Table[tcgeo[x, n], {n, k}]], {x, -1.2, 1.2}, 
              PlotPoints -> 51, DisplayFunction -> Identity ], 
            g5},  DisplayFunction -> $DisplayFunction, 
          PlotRange ->  {{-1.2, 1.2}, {-0.2, 3}}], {k, 16, 
          16}];

Do[
        Show[{g5, 
            Plot[Evaluate[Table[tcgeo[x, n], {n, k}]], {x, -1.2, 1.2}, 
              PlotPoints -> 51, DisplayFunction -> Identity ], 
            g5},  DisplayFunction -> $DisplayFunction, 
          PlotRange ->  {{-1.2, 1.2}, {-0.2, 3}}], {k, 1, 
          16}];

Taylorentwicklung von log(x + 1)

tcln[x_, n_] := 
      Normal[Series[Log[u + 1], {u, 0, n}]] /. u -> x

g6 = 
        Plot[Log[x + 1], {x, -0.95, 
            2}, 
AspectRatio  -> 
            Automatic, 
PlotRange ->  {{-1.1, 
                2.1}, {-2.1, 2.1}}, 
PlotPoints -> 
            51, 
Ticks -> {{-1, -0.5, 0.5, 1, 
                1.5, 2}, {-2, -1, 1, 2}}, 
          PlotStyle -> {Red, 
              aT[2]}, 
PlotLabel -> "Taylorentwicklung \
von log(x + 1)\n"];

Do[
        Show[{g6, 
            Plot[Evaluate[Table[tcln[x, n], {n, k}]], {x, -1, 2}, 
              PlotPoints -> 
                51, 
DisplayFunction -> Identity ], 
            g6},  DisplayFunction -> $DisplayFunction, 
PlotRange ->  {{-1.1, 2.1}, {-2.1, 
                2.1}}], {k, 16, 16}];

Do[
        Show[{g6, 
            Plot[Evaluate[Table[tcln[x, n], {n, k}]], {x, -1, 2}, 
              PlotPoints -> 
                51, 
DisplayFunction -> Identity ], 
            g6},  DisplayFunction -> $DisplayFunction, 
PlotRange ->  {{-1.1, 2.1}, {-2.1, 
                2.1}}], {k, 1, 16}];

Taylorentwicklung von arctan

tcarctan[x_, n_] := 
      Normal[Series[ArcTan[u], {u, 0, n}]] /. u -> x

g7 = 
        Plot[ArcTan[x], {x, -2, 
            2}, 
AspectRatio  -> 
            Automatic, 
PlotRange ->  {{-2.1, 
                2.1}, {-2.1, 2.1}}, 
PlotPoints -> 
            51, 
Ticks -> {{-2, -1, 1, 
                2}, {-2, -1, 1, 2}}, 
          PlotStyle -> {Red, 
              aT[2]}, 
PlotLabel -> "Taylorentwicklung \
von arctan\n"];

Do[
        Show[{g7, 
            Plot[Evaluate[Table[tcarctan[x, n], {n, k}]], {x, -2, 2}, 
              PlotPoints -> 
                51, 
DisplayFunction -> Identity ], 
            g7},  DisplayFunction -> $DisplayFunction, 
PlotRange ->  {{-2.1, 2.1}, {-2.1, 
                2.1}}], {k, 24, 24}];

Do[
        Show[{g7, 
            Plot[Evaluate[Table[tcarctan[x, n], {n, k}]], {x, -2, 2}, 
              PlotPoints -> 
                51, 
DisplayFunction -> Identity ], 
            g7},  DisplayFunction -> $DisplayFunction, 
PlotRange ->  {{-2.1, 2.1}, {-2.1, 
                2.1}}], {k, 1, 24}];