2019年2月5日火曜日

学習環境

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


  1. 2π0πr22πdθ=122π0(2+sin(2θ))2dθ=122π0(4+4sin(2θ)+sin2(2θ))dθ=12[4θ-2cos(2θ)]2π0+122π0sin2(2θ)dθ=12·8π+122π0sin2(2θ)dθt=2θdtdθ=2sin2t·12dt=12(-sintcost+121dt)=12(-sintcost+12t)θ=0,t=0θ=2π,t=4π4π0sin2t·12dt=12([-sintcost]4π0+12[t]4π0)=π4π+12·π=92π

コード

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 + sin(2 * 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('sample4.png')

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

$ python3 sample3.py
2⋅π                  
 ⌠                   
 ⎮  ⎛  cos(θ)   1⎞   
 ⎮  ⎜- ────── + ─⎟ dθ
 ⎮  ⎝    2      2⎠   
 ⌡                   
 0                   

π

$

落花生っぽい(?)形になった。

0 コメント:

コメントを投稿