## 2019年12月3日火曜日

### 数学 - Pytho - 微分積分学 - 平均値の定理 - 一点を通る直線、x軸とy軸との交点、線分、長さ、最小値

1. P の座標を

$\begin{array}{l}\left(p,0\right)\\ p>0\end{array}$

Q の座標を

$\begin{array}{l}\left(0,q\right)\\ q>0\end{array}$

とおく。

P 、 Q、点(a, b)を通る直線は、

$\begin{array}{l}f\left(x\right)=-\frac{q}{p}\left(x-a\right)+b\\ a>0,b>0\end{array}$

線分 PQ の長さの2乗

${p}^{2}+{q}^{2}$

の最小値を求める。

$\begin{array}{l}f\left(p\right)=-\frac{q}{p}\left(p-a\right)+b=0\\ -q+\frac{q}{p}a+b=0\\ -pq+qa+bp=0\\ \left(a-p\right)q=-bp\\ q=\frac{bp}{p-a}\\ g\left(p\right)={p}^{2}+{\left(\frac{bp}{p-a}\right)}^{2}\\ ={p}^{2}+\frac{{b}^{2}{p}^{2}}{{\left(p-a\right)}^{2}}\\ g\text{'}\left(p\right)\\ =2p+\frac{2{b}^{2}p{\left(p-a\right)}^{2}-{b}^{2}{p}^{2}2\left(p-a\right)}{{\left(p-a\right)}^{4}}\\ =2p\left(1+\frac{{b}^{2}\left(p-a-p\right)}{{\left(p-a\right)}^{3}}\right)\\ =2p\left(1-\frac{a{b}^{2}}{{\left(p-a\right)}^{3}}\right)\\ {\left(p-a\right)}^{3}=a{b}^{2}\\ p-a={\left(a{b}^{2}\right)}^{\frac{1}{3}}\\ p=a+{a}^{\frac{1}{3}}{b}^{\frac{2}{3}}\\ g\left(a+{a}^{\frac{1}{3}}{b}^{\frac{2}{3}}\right)\\ ={\left(a+{a}^{\frac{1}{3}}{b}^{\frac{2}{3}}\right)}^{2}\left(1+\frac{{b}^{2}}{{\left(a+{a}^{\frac{1}{3}}{b}^{\frac{2}{3}}-a\right)}^{2}}\right)\\ ={a}^{\frac{2}{3}}{\left({a}^{\frac{2}{3}}+{b}^{\frac{2}{3}}\right)}^{2}\left(1+\frac{{b}^{2}}{{a}^{\frac{2}{3}}{b}^{\frac{4}{3}}}\right)\\ ={\left({a}^{\frac{2}{3}}+{b}^{\frac{2}{3}}\right)}^{3}\end{array}$

よって求める 線分の長さの最小値は、

$\left|PQ\right|={\left({a}^{\frac{2}{3}}+{b}^{\frac{2}{3}}\right)}^{\frac{3}{2}}$

コード

#!/usr/bin/env python3
from sympy import pprint, symbols, plot, Derivative, Rational, solveset, Interval

print('14.')

x, m, p = symbols('x, m, p', real=True)
a = 2
b = 3
q = b * p / (p - a)
m = -p / q
f = m * (x - a) + b

p0 = a + a ** Rational(1, 3) * b ** Rational(2, 3)
fs = [f.subs({p: p0 + i}) for i in range(-2, 3)]
p = plot(*fs,
(x, 0, 10),
ylim=(0, 10),
legend=True,
show=False)

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

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

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


 % ./sample14.py
14.
%