2019年7月8日月曜日

学習環境

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


  1. f x = cos x - 1 + x 2 2 ! f ' x = - sin x + x f 2 x = - cos x + 1 f 3 x = sin x f 4 x = cos x f 5 x = - sin x f 6 x = - cos x f 7 x = sin x f x = 1 4 ! x 4 - 1 6 ! x 6 + lim x 0 cos x - 1 + x 2 2 ! x 3 = 0 lim x 0 cos x - 1 + x 2 2 ! x 4 = 1 4 !

コード

Python 3

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

print('40.')

x = symbols('x')
num = cos(x) - 1 + x ** 2 / factorial(2)
f = num / x ** 3
g = num / x ** 4
for h in f, g:
    for d in ['+', '-']:
        l = Limit(h, x, 0, dir=d)
        for o in [l, l.doit()]:
            pprint(o)
            print()

p = plot(num, x ** 3, x ** 4, f, g,
         (x, -1, 1),
         ylim=(-1, 1),
         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('sample40.png')

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

C:\Users\...>py sample40.py
40.
     ⎛ 2             ⎞
     ⎜x              ⎟
     ⎜── + cos(x) - 1⎟
     ⎜2              ⎟
 lim ⎜───────────────⎟
x─→0⁺⎜        3      ⎟
     ⎝       x       ⎠

0

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

0

     ⎛ 2             ⎞
     ⎜x              ⎟
     ⎜── + cos(x) - 1⎟
     ⎜2              ⎟
 lim ⎜───────────────⎟
x─→0⁺⎜        4      ⎟
     ⎝       x       ⎠

1/24

     ⎛ 2             ⎞
     ⎜x              ⎟
     ⎜── + cos(x) - 1⎟
     ⎜2              ⎟
 lim ⎜───────────────⎟
x─→0⁻⎜        4      ⎟
     ⎝       x       ⎠

1/24


C:\Users\...>

0 コメント:

コメントを投稿