2020年2月18日火曜日

学習環境

解析入門(上) (松坂和夫 数学入門シリーズ 4) (松坂 和夫(著)、岩波書店)の第9章(関数列と関数級数)、9.2(整級数)、問題4の解答を求めてみる。


  1. x < 1 log 1 + x = n = 1 - 1 n - 1 x n n log 1 - x = log 1 + - x = n = 1 - 1 n - 1 - x n n = n = 1 - 1 2 n - 1 x n n = - n = 1 x n n 1 2 log 1 + x 1 - x = 1 2 log 1 + x - log 1 - x = 1 2 n = 1 - 1 n - 1 x n n + n = 1 x n n = 1 2 n = 1 - 1 n - 1 + 1 x n n = 1 2 n = 1 2 · x 2 n - 1 2 n - 1 = n = 1 x 2 n - 1 2 n - 1 = n = 0 x 2 n + 1 2 n + 1

コード

#!/usr/bin/env python3
from sympy import symbols, log, summation, pprint, plot

print('4.')

x = symbols('x')
n = symbols('n', integer=True)
f = log((1 + x) / (1 - x)) / 2
g = x ** (2 * n + 1) / (2 * n + 1)
gs = [sum([g.subs({n: k}) for k in range(n0)])
      for n0 in range(9)]

p = plot(f, *gs,
         (x, -0.9, 3),
         ylim=(-2, 2),
         legend=False,
         show=False)

colors = ['red', 'green', 'blue', 'brown', 'orange',
          'purple', 'pink', 'gray', 'skyblue', 'yellow']

for o, color in zip(p, colors):
    o.line_color = color

for o in zip([f] + gs, colors):
    pprint(o)

p.show()
p.save('sample4.png')

入出力結果(Zsh、PowerShell、Terminal、Jupyter(IPython))

% ./sample4.py
4.
⎛   ⎛x + 1⎞     ⎞
⎜log⎜─────⎟     ⎟
⎜   ⎝1 - x⎠     ⎟
⎜──────────, red⎟
⎝    2          ⎠
(0, green)
(x, blue)
⎛ 3           ⎞
⎜x            ⎟
⎜── + x, brown⎟
⎝3            ⎠
⎛ 5    3            ⎞
⎜x    x             ⎟
⎜── + ── + x, orange⎟
⎝5    3             ⎠
⎛ 7    5    3            ⎞
⎜x    x    x             ⎟
⎜── + ── + ── + x, purple⎟
⎝7    5    3             ⎠
⎛ 9    7    5    3          ⎞
⎜x    x    x    x           ⎟
⎜── + ── + ── + ── + x, pink⎟
⎝9    7    5    3           ⎠
⎛ 11    9    7    5    3          ⎞
⎜x     x    x    x    x           ⎟
⎜─── + ── + ── + ── + ── + x, gray⎟
⎝ 11   9    7    5    3           ⎠
⎛ 13    11    9    7    5    3             ⎞
⎜x     x     x    x    x    x              ⎟
⎜─── + ─── + ── + ── + ── + ── + x, skyblue⎟
⎝ 13    11   9    7    5    3              ⎠
⎛ 15    13    11    9    7    5    3            ⎞
⎜x     x     x     x    x    x    x             ⎟
⎜─── + ─── + ─── + ── + ── + ── + ── + x, yellow⎟
⎝ 15    13    11   9    7    5    3             ⎠
%

0 コメント:

コメントを投稿