## 2019年2月14日木曜日

### 数学 - Python - 解析学 - 積分 - 積分の応用 - 面積(累乗(立方)、2つつの曲線で囲まれた面積、直交座標)

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

コード

Python 3

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

x = symbols('x')
f = x ** 3 + 1
g = x ** 3 + x ** 2
I = Integral(f - g, (x, -1, 1))

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

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

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

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


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

4/3

C:\Users\...>