## 2020年6月21日日曜日

### 数学 - Python - 代数学 - 1次関数、2次関数 - 直線、22次関数の最大値と最小値、頂点

1. $y=\frac{-4x+10}{3}$
$4{x}^{2}+3{y}^{2}$
$=4{x}^{2}+3·\frac{{4}^{2}{x}^{2}-2·4·10x+1{0}^{2}}{{3}^{2}}$
$=\left(4+\frac{{4}^{2}}{3}\right){x}^{2}-\frac{{2}^{4}·5}{3}x+\frac{1{0}^{2}}{3}$

よって、 求める最小値は

$-\frac{{\left(\frac{{2}^{4}·5}{3}\right)}^{2}-4·\left(4+\frac{{4}^{2}}{3}\right)·\frac{1{0}^{2}}{3}}{4\left(4+\frac{{4}^{2}}{3}\right)}$
$=-\frac{{2}^{8}·{5}^{2}}{{3}^{2}}·\frac{1}{{2}^{2}\left({2}^{2}+\frac{{2}^{4}}{3}\right)}+\frac{1{0}^{2}}{3}$
$=-\frac{{2}^{8}·{5}^{2}}{{3}^{2}}·\frac{1}{{2}^{4}+\frac{{2}^{6}}{3}}+\frac{1{0}^{2}}{3}$
$=-\frac{{2}^{8}·3·{5}^{2}}{{3}^{2}\left({2}^{4}·3+{2}^{6}\right)}+\frac{1{0}^{2}}{3}$
$=-\frac{{2}^{8}·3·{5}^{2}}{{2}^{4}·{3}^{2}\left(3+{2}^{2}\right)}+\frac{1{0}^{2}}{3}$
$=-\frac{{2}^{4}·{5}^{2}}{3·7}+\frac{{2}^{2}·{5}^{2}}{3}$
$=\frac{-{2}^{4}·{5}^{2}+{2}^{2}·{5}^{2}·7}{3·7}$
$=\frac{{2}^{2}·{5}^{2}\left(-{2}^{2}+7\right)}{3·7}$
$=\frac{4·25}{7}$
$=\frac{100}{7}$

2. $4{x}^{2}-3{y}^{2}$
$={2}^{2}{x}^{2}-3{\left(\frac{-{2}^{2}x+2·5}{3}\right)}^{2}$
$={2}^{2}\left(1-\frac{{2}^{2}}{3}\right){x}^{2}+\frac{{2}^{4}·5}{3}x-\frac{{2}^{2}·{5}^{2}}{3}$

よって、求める最大値は、

$-\frac{{\left(\frac{{2}^{4}·5}{3}\right)}^{2}-4·{2}^{2}\left(-\frac{1}{3}\right)\left(-\frac{{2}^{2}·{5}^{2}}{3}\right)}{4·{2}^{2}\left(-\frac{1}{3}\right)}$
$=\frac{\frac{{2}^{8}·{5}^{2}}{{3}^{2}}}{\frac{{2}^{4}}{3}}-\frac{{2}^{2}·{5}^{2}}{3}$
$=\frac{{2}^{8}·{5}^{2}}{{2}^{4}·3}-\frac{{2}^{2}·{5}^{2}}{3}$
$=\frac{{2}^{4}·{5}^{2}}{3}-\frac{{2}^{2}·{5}^{2}}{3}$
$=\frac{{2}^{2}·{5}^{2}\left({2}^{2}-1\right)}{3}$
$={2}^{2}·{5}^{2}$
$=100$

コード

#!/usr/bin/env python3
from unittest import TestCase, main
from sympy import plot, Rational
from sympy.abc import x

print('11.')

y = (-4 * x + 10) / 3
y1 = 4 * x ** 2 + 3 * y ** 2
y2 = 4 * x ** 2 - 3 * y ** 2

p = plot(y1, y2, Rational(100, 7), 100,
(x, -5, 15),
ylim=(Rational(100, 7), 100),
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('sample11.png')

% ./sample11.py
11.
%