## 2019年12月20日金曜日

### 数学 - Python - 微分積分学 - 平均値の定理 - 閉区間で連続で開区間で微分可能な関数、行列式、ロルの定理

1. 関数 g を

$\begin{array}{l}g\left(x\right)\\ =\mathrm{det}\left[\begin{array}{ccc}f\left(a\right)& \phi \left(a\right)& \psi \left(a\right)\\ f\left(b\right)& \phi \left(b\right)& \psi \left(b\right)\\ f\left(x\right)& \phi \left(x\right)& \psi \left(x\right)\end{array}\right]\\ =f\left(a\right)\phi \left(b\right)\psi \left(x\right)+\phi \left(a\right)\psi \left(b\right)f\left(x\right)+\psi \left(a\right)f\left(b\right)\phi \left(x\right)\\ -f\left(a\right)\psi \left(b\right)\phi \left(x\right)-\phi \left(a\right)f\left(b\right)\psi \left(x\right)-\psi \left(a\right)\phi \left(b\right)f\left(x\right)\end{array}$

とおく。

このとき、

$\begin{array}{l}g\left(a\right)=0\\ g\left(b\right)=0\\ g\text{'}\left(x\right)=f\left(a\right)\phi \left(b\right)\psi \text{'}\left(x\right)+\phi \left(a\right)\psi \left(b\right)f\text{'}\left(x\right)+\psi \left(a\right)f\left(b\right)\phi \text{'}\left(x\right)\\ -f\left(a\right)\psi \left(b\right)\phi \text{'}\left(x\right)-\phi \left(a\right)f\left(b\right)\psi \text{'}\left(x\right)-\psi \left(a\right)\phi \left(b\right)f\text{'}\left(x\right)\\ =\mathrm{det}\left[\begin{array}{ccc}f\left(a\right)& \phi \left(a\right)& \psi \left(a\right)\\ f\left(b\right)& \psi \left(b\right)& \psi \left(b\right)\\ f\text{'}\left(x\right)& \phi \text{'}\left(x\right)& \psi \text{'}\left(x\right)\end{array}\right]\end{array}$

ロルの定理により、

$\begin{array}{l}a<\xi

を満たすものが存在する。

（証明終）

コード

#!/usr/bin/env python3
from unittest import TestCase, main
from sympy import pprint, symbols, Matrix, plot, solveset, Derivative, Interval

print('22.')

x = symbols('x', real=True)
f = x / 10 + 2
g = x ** 2 / 20
h = x ** 3 / 30
a = -2
b = 3
d = Matrix([[t.subs({x: x0})for x0 in [a, b, x]]
for t in [f, g, h]]).det()

d1 = Derivative(d, x, 1).doit()
fs = [f, g, h, d, d1]

class MyTestCase(TestCase):
def test(self):
s = solveset(d1, domain=Interval.open(a, b))
self.assertGreater(len(s), 0)

p = plot(*fs,
(x, -5, 5),
ylim=(-5, 5),
legend=False,
show=False)

colors = ['red', 'green', 'blue', 'brown', 'orange',
'purple', 'pink', 'gray', 'skyblue', 'yellow']

for o, color in zip(p, colors):
o.line_color = color

for o in zip(fs, colors):
pprint(o)

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

if __name__ == '__main__':
main()


% ./sample22.py -v
22.
⎛x          ⎞
⎜── + 2, red⎟
⎝10         ⎠
⎛ 2       ⎞
⎜x        ⎟
⎜──, green⎟
⎝20       ⎠
⎛ 3      ⎞
⎜x       ⎟
⎜──, blue⎟
⎝30      ⎠
⎛   3       2                 ⎞
⎜7⋅x    67⋅x    3⋅x   3       ⎟
⎜──── - ───── + ─── + ─, brown⎟
⎝600     600    100   5       ⎠
⎛   2                     ⎞
⎜7⋅x    67⋅x    3         ⎟
⎜──── - ──── + ───, orange⎟
⎝200    300    100        ⎠
test (__main__.MyTestCase) ... ok

----------------------------------------------------------------------
Ran 1 test in 0.044s

OK
%