2019年2月3日日曜日

学習環境

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


  1. 2π012π·πr2dθ=2π012r2dθ=122π0(1-cosθ)2dθ=122π0(1-2cosθ+cos2θ)dθ=12([θ-2sinθ]2π0+12[cosθsinθ]2π0+122π01dθ)=12(2π+12·2π)=π2(2+1)=32π

コード

Python 3

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

theta = symbols('θ')
r = 1 - 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']
for i, s in enumerate(p):
    s.line_color = colors[i]
p.save('sample2.png')

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

$ python3 sample2.py
2⋅π                 
 ⌠                  
 ⎮              2   
 ⎮  (cos(θ) - 1)    
 ⎮  ───────────── dθ
 ⎮        2         
 ⌡                  
 0                  

3⋅π
───
 2 

$

0 コメント:

コメントを投稿