## 2019年2月13日水曜日

### 数学 - Python - 解析学 - 積分 - 積分の応用 - 面積(2つの放物線、累乗(平方)、直交座標)

1. $\begin{array}{}\underset{-2}{\overset{2}{\int }}\left(\left(8-2{x}^{2}\right)-\left(4-{x}^{2}\right)\right)\mathrm{dx}\\ =\underset{-2}{\overset{2}{\int }}\left(4-{x}^{2}\right)\mathrm{dx}\\ =2\underset{0}{\overset{2}{\int }}\left(4-{x}^{2}\right)\mathrm{dx}\\ =2{\left[4x-\frac{1}{3}{x}^{3}\right]}_{0}^{2}\\ =2\left(8-\frac{8}{3}\right)\\ =2·\frac{16}{3}\\ =\frac{32}{3}\end{array}$

コード

Python 3

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

x = symbols('x')
f = 8 - 2 * x ** 2
g = 4 - x ** 2
I = Integral(f - g, (x, -2, 2))

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

p = plot((f, (x, -5, -2)),
(f, (x, -2, 2)),
(f, (x, 2, 5)),
(g, (x, -5, -2)),
(g, (x, -2, 2)),
(g, (x, 2, 5)),
legend=True,
show=False)

colors = ['red', 'green', 'blue', 'brown', 'orange', 'pink']

for i, s in enumerate(p):
s.line_color = colors[i]
p.save('sample12.png')


C:\Users\...> py -3 sample12.py
2
⌠
⎮  ⎛   2    ⎞
⎮  ⎝- x  + 4⎠ dx
⌡
-2

32/3

C:\Users\...>