2019年2月11日月曜日

学習環境

解析入門 原書第3版 (S.ラング(著)、松坂 和夫(翻訳)、片山 孝次(翻訳)、岩波書店)の第3部(積分)、第13章(積分の応用)、補充問題、面積の練習問題10の解答を求めてみる。


  1. π r 2 2 π d θ = 1 2 2 + cos θ 2 d θ = 1 2 4 + 4 cos θ + cos 2 θ d θ = 1 2 4 θ + 4 sin θ + 1 2 cos θ sin θ + 1 2 1 d θ = 2 θ + 2 sin θ + 1 4 cos θ sin θ + θ 2 θ + 2 sin θ + 1 4 cos θ sin θ + θ 0 2 π = 4 π + π 2 = 9 2 π

コード

Python 3

#!/usr/bin/env python3
from sympy import pprint, symbols, Integral, cos, sin, pi, exp, sqrt
from sympy.plotting import plot_parametric

theta = symbols('θ')
r = 2 + cos(theta)
x = r * cos(theta)
y = r * sin(theta)

I = Integral(r ** 2 / 2, (theta, 0, 2 * pi))
for o in [I, I.doit()]:
    pprint(o.simplify())
    print()

p = plot_parametric((x, y, (theta, 0, pi / 2)),
                    (x, y, (theta, pi / 2, pi)),
                    (x, y, (theta, pi, 3 * pi / 2)),
                    (x, y, (theta, 3 * pi / 2, 2 * pi)),
                    show=False)


colors = ['red', 'green', 'blue', 'brown', 'orange', 'pink']
for i, s in enumerate(p):
    s.line_color = colors[i]
p.save('sample10.png')

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

C:\Users\...> py -3 sample10.py
2⋅π                 
 ⌠                  
 ⎮              2   
 ⎮  (cos(θ) + 2)    
 ⎮  ───────────── dθ
 ⎮        2         
 ⌡                  
 0                  

9⋅π
───
 2 


C:\Users\...>

0 コメント:

コメントを投稿