## 2019年2月17日日曜日

### 数学 - Python - 解析学 - 積分 - 積分の応用 - 面積(直線、累乗(立方)、交点、直交座標)

1. $\begin{array}{}{x}^{3}=x+6\\ {x}^{3}-x-6=0\\ \left(x-2\right)\left({x}^{2}+2x+3\right)=0\end{array}$

よって、

$a=2$

ゆえに求める面積は、

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

コード

Python 3

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

x = symbols('x')
f = x + 6
g = x ** 3
xs = solve(f - g)
pprint(xs)
x1 = 0
x2 = xs[0]
I = Integral(f - g, (x, x1, x2))

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

a, b, c, d = x1 - 1, x1, x2, x2 + 1
p = plot((f, (x, a, b)),
(f, (x, b, c)),
(f, (x, c, d)),
(g, (x, a, b)),
(g, (x, b, c)),
(g, (x, c, d)),
legend=True,
show=False)

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

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


C:\Users\...> py -3 sample16.py
[2, -1 - √2⋅ⅈ, -1 + √2⋅ⅈ]
2
⌠
⎮ ⎛   3        ⎞
⎮ ⎝- x  + x + 6⎠ dx
⌡
0

10

C:\Users\...>