Mathematica プレゼンテーション・サンプル

\(\(\@2\) の近似分数の生成\)　−−方程式 (x^2)=\(2 から出発する\)

方程式に一次式を加える

\(TraditionalForm
      \`\(x\^2 + x = 2 + x, x\_0 = 1, \ より：\)\)

\(x0 = 1; p[0] = x0; 
n0 = 20; 

    For[i = 1; x = x0, i < n0 + 1, \(i++\), 
	x = \((x + 2)\)/\((x + 1)\); 
      p[i] = N[x]; 
      
Print[i, "; ", x, \ " = ", \ N[x, 20], 
        "; ", N[\(-Log[10, Abs[x - Sqrt[2]]]\)]]
]\)

f[x]=((x + 2)/(x + 1))のグラフ解析

\(Off[ParametricPlot::"ppcom"]; 
f[x_] := \((x + 2)\)/\((x + 1)\); 
    g[t_] := \((3  t + 1)\)/2; 

    l1[t_, i_] := {\((1 - t)\) p[i] + t\ p[i + 1], p[i + 1]}; 

    l2[t_, i_] := {p[i], \((1 - t)\) p[i] + t\ p[i + 1]}; 

    ParametricPlot[{{g[t], g[t]}, {g[t], f[g[t]]}, l1[t, 0], l2[t, 1], 
        l1[t, 1], l2[t, 2], l1[t, 2]}, {t, 0, 1}, PlotPoints -> 200]\)

\(TraditionalForm
    \`\(x\^2 + x = 2 + x, x\_0 = 2, \ より：\)\)

\(x0 = 2; p[0] = x0; 
n0 = 20; 

    For[i = 1; x = x0, i < n0 + 1, \(i++\), 
	x = \((x + 2)\)/\((x + 1)\); 
      p[i] = N[x]; 
      
Print[i, "; ", x, \ " = ", \ N[x, 20], 
        "; ", N[\(-Log[10, Abs[x - Sqrt[2]]]\)]]
]\)

f[x]=((x + 2)/(x + 1))のグラフ解析

\(Off[ParametricPlot::"ppcom"]; 
f[x_] := \((x + 2)\)/\((x + 1)\); 
    g[t_] := \((3  t + 1)\)/2; 

    l1[t_, i_] := {\((1 - t)\) p[i] + t\ p[i + 1], p[i + 1]}; 

    l2[t_, i_] := {p[i], \((1 - t)\) p[i] + t\ p[i + 1]}; 

    ParametricPlot[{{g[t], g[t]}, {g[t], f[g[t]]}, l1[t, 0], l2[t, 1], 
        l1[t, 1], l2[t, 2], l1[t, 2]}, {t, 0, 1}, PlotPoints -> 200]\)

\(TraditionalForm
      \`\(x\^2 + 2  x = 2 + 2  x, x\_0 = 1, \ より：\)\)

\(x0 = 1; p[0] = x0; 
n0 = 20; 

    For[i = 1; x = x0, i < n0 + 1, \(i++\), 
	
      x = \((2  x + 2)\)/\((x + 2)\); p[i] = N[x]; 
      Print[i, "; ", x, \ " = ", \ N[x, 20], "; ", 
        N[\(-Log[10, Abs[x - Sqrt[2]]]\)]]
]\)

f[x]=((x + 2)/(x + 1))のグラフ解析

\(Off[ParametricPlot::"ppcom"]; 

    f[x_] := \((2  x + 2)\)/\((x + 2)\); g[t_] := \((3  t + 1)\)/2; 

    l1[t_, i_] := {\((1 - t)\) p[i] + t\ p[i + 1], p[i + 1]}; 

    l2[t_, i_] := {p[i], \((1 - t)\) p[i] + t\ p[i + 1]}; 

    ParametricPlot[{{g[t], g[t]}, {g[t], f[g[t]]}, l1[t, 0], l2[t, 1], 
        l1[t, 1], l2[t, 2], l1[t, 2]}, {t, 0, 1}, PlotPoints -> 200]\)

2次式を加える（含・ニュートン法）

\(TraditionalForm
      \`\(2  x\^2 = 2 + x\^2, x\_0 = 1, \ より：\)\)

\(x0 = 1; p[0] = x0; 
n0 = 10; 

    For[i = 1; x = x0, i < n0 + 1, \(i++\), 
	x = 1/x + x/2; p[i] = N[x]; 

      	Print[i, "; ", x, \ " = ", \ N[x, 20], "; ", 
        Block[{$MaxExtraPrecision\  = \ 1000}, 
          N[\(-Log[10, Abs[N[x - Sqrt[2], 1000]]]\)]]]
]\)

f[x]=(1/x) + (x/2)のグラフ解析

\(Off[ParametricPlot::"ppcom"]; 
f[x_] := 1/x + x/2; 
    g[t_] := \((3  t + 1)\)/2; 

    l1[t_, i_] := {\((1 - t)\) p[i] + t\ p[i + 1], p[i + 1]}; 

    l2[t_, i_] := {p[i], \((1 - t)\) p[i] + t\ p[i + 1]}; 

    ParametricPlot[{{g[t], g[t]}, {g[t], f[g[t]]}, l1[t, 0], l2[t, 1], 
        l1[t, 1], l2[t, 2]}, {t, 0, 1}, PlotPoints -> 200]\)