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

2019年1月29日火曜日

学習環境

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


  1. π40(1+cosθ)2+(ddθ(1+cosθ))2dθ=π401+2cosθ+cos2θ+(-sinθ)2dθ=π401+2cosθ+cos2θ+sin2θdθ=2π401+cosθdθ=2π401+cos(θ2+θ2)dθ=2π401+cos2(θ2)-sin2(θ2)dθ=2π401+cos2(θ2)-(1-cos2(θ2))dθ=2π402cos2(θ2)dθ=2π40cos(θ2)dθ=2[2sin(θ2)]π40=4sinπ8

コード

Python 3

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

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

I = Integral(sqrt(r ** 2 + Derivative(r, theta, 1) ** 2),
             (theta, 0, pi / 4))

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

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

for o in [I.doit(), 4 * sin(pi / 8)]:
    print(float(o))

p = plot_parametric((x, y, (theta, -pi, 0)),
                    (x, y, (theta, 0, pi / 4)),
                    (x, y, (theta, pi / 4, pi)),
                    show=False)

colors = ['red', 'green', 'blue']
for i, color in enumerate(colors):
    p[i].line_color = color
p.save('sample18.png')

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

$ python3 sample18.py
π                                            
─                                            
4                                            
⌠                                            
⎮      ___________________________________   
⎮     ╱                                 2    
⎮    ╱              2   ⎛d             ⎞     
⎮   ╱   (cos(θ) + 1)  + ⎜──(cos(θ) + 1)⎟   dθ
⎮ ╲╱                    ⎝dθ            ⎠     
⌡                                            
0                                            

π                    
─                    
4                    
⌠                    
⎮   ______________   
⎮ ╲╱ 2⋅cos(θ) + 2  dθ
⌡                    
0                    

  π          
  ─          
  4          
  ⌠          
  ⎮    ⎛θ⎞   
2⋅⎮ cos⎜─⎟ dθ
  ⎮    ⎝2⎠   
  ⌡          
  0          

    _________
2⋅╲╱ -√2 + 2 

1.5307337294603591
1.5307337294603591
$

0 コメント:

コメントを投稿