## 2019年2月23日土曜日

### 数学 - Python - 解析学 - 積分 - 積分の応用 - 回転体の体積(平方根、累乗(べき乗、立方)、図形をx軸の周りに回転してできる立体の体積)

1. $\begin{array}{}{x}^{3}=\sqrt{x}\\ {x}^{6}=x\\ {x}^{6}-x=0\\ x\left({x}^{5}-1\right)=0\\ \underset{0}{\overset{1}{\int }}\pi {\left(\sqrt{x}\right)}^{2}\mathrm{dx}-\underset{0}{\overset{1}{\int }}\pi {\left({x}^{3}\right)}^{2}\mathrm{dx}\\ =\pi \underset{0}{\overset{1}{\int }}\left(x-{x}^{6}\right)\mathrm{dx}\\ =\pi {\left[\frac{1}{2}{x}^{2}-\frac{1}{7}{x}^{7}\right]}_{0}^{1}\\ =\pi \left(\frac{1}{2}-\frac{1}{7}\right)\\ =\frac{5}{14}\pi \end{array}$

コード

Python 3

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

x = symbols('x')
f = sqrt(x)
g = x ** 3
x1, x2 = solve(f - g)[:2]

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

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

p = plot((f, (x, -1, x1)),
(f, (x, x1, x2)),
(f, (x, x2, 2)),
(g, (x, -1, x1)),
(g, (x, x1, x2)),
(g, (x, x2, 2)),
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('sample6.png')


C:\Users\...> py -3 sample6.py
1
⌠           1
⎮    6      ⌠
- ⎮ π⋅x  dx + ⎮ π⋅x dx
⌡           ⌡
0           0

5⋅π
───
14

C:\Users\...>