2018年12月13日木曜日

数学 - Python - 解析学 - 重積分の変数変換 - 変数変換定理(球面の内側、円錐面の外側、体積、空間極座標、積分、三角関数(余弦、正弦)、累乗(べき乗))

1. 空間極座標に変換する。

$r,\theta$

の値の範囲を考える。

$\begin{array}{}0\le \theta \le \frac{\pi }{2}\\ {\left(r\mathrm{sin}\theta \mathrm{cos}\phi \right)}^{2}+{\left(r\mathrm{sin}\theta \mathrm{sin}\phi \right)}^{2}\le {\left(r\mathrm{cos}\theta \right)}^{2}\\ {\mathrm{sin}}^{2}\theta {\mathrm{cos}}^{2}\phi +{\mathrm{sin}}^{2}\theta {\mathrm{sin}}^{2}\phi \le {\mathrm{cos}}^{2}\theta \\ {\mathrm{sin}}^{2}\theta \le {\mathrm{cos}}^{2}\theta \\ 0\le \theta \le \frac{\pi }{4}\\ {r}^{2}{\mathrm{sin}}^{2}\theta {\mathrm{cos}}^{2}\phi +{r}^{2}{\mathrm{sin}}^{2}\theta {\mathrm{sin}}^{2}\phi +{r}^{2}{\mathrm{cos}}^{2}\theta =r\mathrm{cos}\theta \\ {r}^{2}{\mathrm{sin}}^{2}\theta +{r}^{2}{\mathrm{cos}}^{2}\theta =r\mathrm{cos}\theta \\ {r}^{2}=r\mathrm{cos}\theta \\ r=\mathrm{cos}\theta \\ 0\le r\le \mathrm{cos}\theta \end{array}$

よって、求める問題の球面の内側 にあって、円錐面の上側にある部分の体積は、

$\begin{array}{}\underset{0}{\overset{2\pi }{\int }}\underset{0}{\overset{\frac{\pi }{4}}{\int }}{\int }_{0}^{\mathrm{cos}\theta }{r}^{2}\mathrm{sin}\theta drd\theta d\phi \\ =\frac{1}{3}\underset{0}{\overset{2\pi }{\int }}\underset{0}{\overset{\frac{\pi }{4}}{\int }}{\left[{r}^{3}\mathrm{sin}\theta \right]}_{0}^{\mathrm{cos}\theta }d\theta d\phi \\ =\frac{1}{3}{\int }_{0}^{2\pi }\underset{0}{\overset{\frac{\pi }{4}}{\int }}{\mathrm{cos}}^{3}\theta \mathrm{sin}\theta d\theta d\phi \\ =\frac{1}{3}\left(-\frac{1}{4}\right){\int }_{0}^{2\pi }{\left[{\mathrm{cos}}^{4}\theta \right]}_{0}^{\frac{\pi }{4}}d\phi \\ =-\frac{1}{12}{\int }_{0}^{2\pi }\left(\frac{1}{4}-1\right)d\phi \\ =\left(-\frac{1}{12}\right)\left(-\frac{3}{4}\right){\int }_{0}^{2\pi }1d\phi \\ =\frac{1}{16}2\pi \\ =\frac{\pi }{8}\end{array}$

コード(Emacs)

Python 3

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

print('6.')

r, theta, phi = symbols('r, θ, φ')

I = Integral(Integral(Integral(r ** 2 * sin(theta), (r, 0, cos(theta))),
(theta, 0, pi / 4)),
(phi, 0, 2 * pi))

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


$./sample6.py 6. π ─ 2⋅π 4 cos(θ) ⌠ ⌠ ⌠ ⎮ ⎮ ⎮ 2 ⎮ ⎮ ⎮ r ⋅sin(θ) dr dθ dφ ⌡ ⌡ ⌡ 0 0 0 π ─ 8$