## 2019年2月28日木曜日

### 数学 - Python - 解析学 - 積分 - 積分の応用 - 回転体の体積(三角関数(正接)、図形をx軸の周りに回転してできる立体の体積)

1. $\begin{array}{}\int \pi {y}^{2}\mathrm{dx}\\ =\pi \int {\left(\mathrm{tan}x\right)}^{2}\mathrm{dx}\\ =\pi \int {\left(\frac{\mathrm{sin}x}{\mathrm{cos}x}\right)}^{2}\mathrm{dx}\\ =\pi \int \frac{{\mathrm{sin}}^{2}x}{{\mathrm{cos}}^{2}x}\mathrm{dx}\\ =\pi \int \frac{1-{\mathrm{cos}}^{2}x}{{\mathrm{cos}}^{2}x}\mathrm{dx}\\ =\pi \int \left(\frac{1}{{\mathrm{cos}}^{2}x}-1\right)\mathrm{dx}.\\ =\pi \left(\frac{\mathrm{sin}x}{\mathrm{cos}x}-x\right)\end{array}$

よって、 求める回転体の体積は、

$\begin{array}{}\pi {\left[\frac{\mathrm{sin}x}{\mathrm{cos}x}-x\right]}_{0}^{\frac{\pi }{3}}\\ =\pi \left(\frac{\frac{\sqrt{3}}{2}}{\frac{1}{2}}-\frac{\pi }{3}\right)\\ =\pi \left(\sqrt{3}-\frac{\pi }{3}\right)\end{array}$

コード

Python 3

#!/usr/bin/env python3
from sympy import pprint, symbols, Integral, pi, plot, tan

x = symbols('x')
f = tan(x)
x1, x2 = 0, pi / 3

I = Integral(pi * f ** 2, (x, x1, x2))

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

x0 = -pi
x3 = pi
p = plot((f, (x, x0, x1)),
(f, (x, x1, x2)),
(f, (x, x2, x3)),
ylim=(-5, 5), legend=True, show=False)
colors = ['red', 'green', 'blue', 'brown', 'orange', 'purple']
for s, color in zip(p, colors):
s.line_color = color

p.show()
p.save('sample11.png')


C:\Users\...> py -3 sample11.py
π
─
3
⌠
⎮      2
⎮ π⋅tan (x) dx
⌡
0

π⋅(-π + 3⋅√3)
─────────────
3

C:\Users\...>