Loading [MathJax]/jax/output/CommonHTML/jax.js

2019年3月16日土曜日

学習環境

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


  1. ddxtanx=ddxsinxcosx=cos2x+sin2xcos2x=1cos2xd2dx2tanx=2cosxsinxcos4x=2sinxcos3xd3dx3tanx=2cos4x-2sinx·3cos2x(-sinx)cos6x=2cos4x+6sin2xcos2xcos6xd4dx4tanx=2·Asinxcos12x

    求める4次のテイラー多項式。

    1+23!x3=1+13x3

コード

Python 3

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

print('6.')

x = symbols('x')
f = tan(x)
g = sum([Derivative(f, x, i).subs({x: 0}) * x ** i / factorial(i)
         for i in range(5)])

for o in [g, g.doit()]:
    pprint(o)
    print()

p = plot(tan(x), g.doit(), ylim=(-10, 10), show=False, legend=True)
colors = ['red', 'green', 'blue']
for o, color in zip(p, colors):
    o.line_color = color

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

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

C:\Users\...>py -3 sample6.py
6.
   ⎛  4        ⎞│         ⎛  3        ⎞│         ⎛  2        ⎞│               
 4 ⎜ d         ⎟│       3 ⎜ d         ⎟│       2 ⎜ d         ⎟│               
x ⋅⎜───(tan(x))⎟│      x ⋅⎜───(tan(x))⎟│      x ⋅⎜───(tan(x))⎟│               
   ⎜  4        ⎟│         ⎜  3        ⎟│         ⎜  2        ⎟│               
   ⎝dx         ⎠│x=0      ⎝dx         ⎠│x=0      ⎝dx         ⎠│x=0     ⎛d     
──────────────────── + ──────────────────── + ──────────────────── + x⋅⎜──(tan
         24                     6                      2               ⎝dx    

         
         
         
         
    ⎞│   
(x))⎟│   
    ⎠│x=0

 3    
x     
── + x
3     


C:\Users\...>

0 コメント:

コメントを投稿