## 2020年5月31日日曜日

### 数学 - Python - 代数学 - 1次関数、2次関数 - 2次関数のグラフ - 頂点が描く曲線

1. $\begin{array}{l}y=-2{x}^{2}+2px+p\\ =-2\left({x}^{2}-px\right)+p\\ =-2{\left(x-\frac{p}{2}\right)}^{2}+\frac{{p}^{2}}{2}+p\end{array}$

よって、 この 放物線の頂点は

$\left(\frac{p}{2},\frac{{p}^{2}}{2}+p\right)$
$x=\frac{p}{2},y=\frac{{p}^{2}}{2}+p$

とおき、 p を消去する。

$\begin{array}{l}p=2x\\ y=2{x}^{2}+2x\end{array}$

これが p の値が いろいろに変わるときの放物線の頂点が動く曲線である。

コード

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

print('13.')
x = symbols('x')
ys = [-2 * x ** 2 + 2 * (s * p) * x + s * p
for p in [Rational(1, 2), 1, 3, 4, 5]
for s in [-1, 1]]

p = plot(2 * x ** 2 + 2 * x,
*ys,
(x, -10, 10),
ylim=(-10, 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('sample13.png')


% ./sample13.py
13.
/opt/local/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/sympy/plotting/plot.py:1065: MatplotlibDeprecationWarning:
The set_smart_bounds function was deprecated in Matplotlib 3.2 and will be removed two minor releases later.
self.ax[i].spines['left'].set_smart_bounds(True)
/opt/local/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/sympy/plotting/plot.py:1066: MatplotlibDeprecationWarning:
The set_smart_bounds function was deprecated in Matplotlib 3.2 and will be removed two minor releases later.
self.ax[i].spines['bottom'].set_smart_bounds(False)
%