学習環境
- Surface、Surface ペン(端末)
- Windows 10 Pro (OS)
- Nebo(Windows アプリ)
- iPad Pro 10.5 + Apple Pencil
- MyScript Nebo - MyScript(iPad アプリ(iOS))
- 参考書籍
解析入門 原書第3版 (S.ラング(著)、松坂 和夫(翻訳)、片山 孝次(翻訳)、岩波書店)の第4部(級数)、第14章(テイラーの公式)、4(指数関数)の練習問題9の解答を求めてみる。
小数第4位までは12項。
よって第15項。
コード
Python 3
#!/usr/bin/env python3
from sympy import pprint, symbols, exp, plot, factorial, Derivative, Rational
print('9.')
x = symbols('x')
f = exp(x)
n = 0
is_a = False
while True:
n += 1
g = sum([Derivative(f, x, i).subs({x: 0}) /
factorial(i) * x ** i for i in range(n)]).doit()
r = 2 ** n / factorial(n)
for o in [g, r]:
pprint(o)
print()
if not is_a and 9 * r <= 10 ** -4:
print(f'(a)')
print(f'n = {n}')
fa = g
is_a = True
if 9 * r <= 10 ** -6:
print(f'(b)')
print(f'n = {n}')
fb = g
break
diff = 10 ** -4
p = plot(f, fa, fb, exp(2),
(x, 2 - diff, 2 + diff),
ylim=(float(exp(2)) - diff, float(exp(2)) + diff),
show=False, legend=False)
colors = ['red', 'green', 'blue', 'brown']
for s, color in zip(p, colors):
s.line_color = color
p.show()
p.save('sample9.png')
入出力結果(cmd(コマンドプロンプト)、Terminal、Jupyter(IPython))
C:\Users\...>py sample9.py
9.
1
2
x + 1
2
2
x
── + x + 1
2
4/3
3 2
x x
── + ── + x + 1
6 2
2/3
4 3 2
x x x
── + ── + ── + x + 1
24 6 2
4/15
5 4 3 2
x x x x
─── + ── + ── + ── + x + 1
120 24 6 2
4/45
6 5 4 3 2
x x x x x
─── + ─── + ── + ── + ── + x + 1
720 120 24 6 2
8/315
7 6 5 4 3 2
x x x x x x
──── + ─── + ─── + ── + ── + ── + x + 1
5040 720 120 24 6 2
2/315
8 7 6 5 4 3 2
x x x x x x x
───── + ──── + ─── + ─── + ── + ── + ── + x + 1
40320 5040 720 120 24 6 2
4/2835
9 8 7 6 5 4 3 2
x x x x x x x x
────── + ───── + ──── + ─── + ─── + ── + ── + ── + x + 1
362880 40320 5040 720 120 24 6 2
4/14175
10 9 8 7 6 5 4 3 2
x x x x x x x x x
─────── + ────── + ───── + ──── + ─── + ─── + ── + ── + ── + x + 1
3628800 362880 40320 5040 720 120 24 6 2
8/155925
11 10 9 8 7 6 5 4 3 2
x x x x x x x x x x
──────── + ─────── + ────── + ───── + ──── + ─── + ─── + ── + ── + ── + x + 1
39916800 3628800 362880 40320 5040 720 120 24 6 2
4/467775
(a)
n = 12
12 11 10 9 8 7 6 5 4 3
x x x x x x x x x x
───────── + ──────── + ─────── + ────── + ───── + ──── + ─── + ─── + ── + ── +
479001600 39916800 3628800 362880 40320 5040 720 120 24 6
2
x
── + x + 1
2
8/6081075
13 12 11 10 9 8 7 6
x x x x x x x x x
────────── + ───────── + ──────── + ─────── + ────── + ───── + ──── + ─── + ──
6227020800 479001600 39916800 3628800 362880 40320 5040 720 12
5 4 3 2
x x x
─ + ── + ── + ── + x + 1
0 24 6 2
8/42567525
14 13 12 11 10 9 8
x x x x x x x
─────────── + ────────── + ───────── + ──────── + ─────── + ────── + ───── + ─
87178291200 6227020800 479001600 39916800 3628800 362880 40320 5
7 6 5 4 3 2
x x x x x x
─── + ─── + ─── + ── + ── + ── + x + 1
040 720 120 24 6 2
16
─────────
638512875
(b)
n = 15
C:\Users\...>
0 コメント:
コメントを投稿