2019年6月30日日曜日

学習環境

解析入門 原書第3版 (S.ラング(著)、松坂 和夫(翻訳)、片山 孝次(翻訳)、岩波書店)の第4部(級数)、第14章(テイラーの公式)、補充問題33の解答を求めてみる。



    1. f x - P n x = f n + 1 0 n + 1 ! x n + 1 + . . lim x 0 f x - P n x x 2 = 0

    2. lim x 0 f x - P n x x n = 0

    3. lim x 0 f x - P n x x n - 1 = 0

コード

Python 3

#!/usr/bin/env python3
from sympy import pprint, symbols, plot, Limit, sin, Derivative, factorial

print('33.')

x = symbols('x')
f = sin(x)
n = 4
p = sum([Derivative(f, x, k).subs({x: 0}).doit() / factorial(k) * x ** k
         for k in range(n)])
ns = [2, n, n - 1]
fs = [(f - p) / x ** n0 for n0 in ns]
for i, g in enumerate(fs):
    print(f'({chr(ord("a") + i)})')
    for d in ['+', '-']:
        l = Limit(g, x, 0, dir=d)
        for o in [l, l.doit()]:
            pprint(o)
            print()

p = plot(f, p, *fs,
         (x, -5, 5),
         ylim=(-5, 5),
         legend=True,
         show=False)
colors = ['red', 'green', 'blue', 'brown', 'orange',
          'purple', 'pink', 'gray', 'skyblue', 'yellow']

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

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

入出力結果(Bash、cmd.exe(コマンドプロンプト)、Terminal、Jupyter(IPython))

C:\Users\...>py sample33.py
33.
(a)
     ⎛ 3             ⎞
     ⎜x              ⎟
     ⎜── - x + sin(x)⎟
     ⎜6              ⎟
 lim ⎜───────────────⎟
x─→0⁺⎜        2      ⎟
     ⎝       x       ⎠

0

     ⎛ 3             ⎞
     ⎜x              ⎟
     ⎜── - x + sin(x)⎟
     ⎜6              ⎟
 lim ⎜───────────────⎟
x─→0⁻⎜        2      ⎟
     ⎝       x       ⎠

0

(b)
     ⎛ 3             ⎞
     ⎜x              ⎟
     ⎜── - x + sin(x)⎟
     ⎜6              ⎟
 lim ⎜───────────────⎟
x─→0⁺⎜        4      ⎟
     ⎝       x       ⎠

0

     ⎛ 3             ⎞
     ⎜x              ⎟
     ⎜── - x + sin(x)⎟
     ⎜6              ⎟
 lim ⎜───────────────⎟
x─→0⁻⎜        4      ⎟
     ⎝       x       ⎠

0

(c)
     ⎛ 3             ⎞
     ⎜x              ⎟
     ⎜── - x + sin(x)⎟
     ⎜6              ⎟
 lim ⎜───────────────⎟
x─→0⁺⎜        3      ⎟
     ⎝       x       ⎠

0

     ⎛ 3             ⎞
     ⎜x              ⎟
     ⎜── - x + sin(x)⎟
     ⎜6              ⎟
 lim ⎜───────────────⎟
x─→0⁻⎜        3      ⎟
     ⎝       x       ⎠

0


C:\Users\...>

0 コメント:

コメントを投稿