## 2020年7月30日木曜日

### 数学 - Python - 放物線・だ円・双曲線 - 2次関数 - 2次曲線の平行移動と回転 - 2次曲線の平行移動 - 式の変形、概形の描画

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

2. $\frac{1}{2}{y}^{2}+2=x$

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

4. $4{x}^{2}-24x+9{y}^{2}=0$
$4{\left(x-3\right)}^{2}+9{y}^{2}=36$
$\frac{{\left(x-3\right)}^{2}}{{3}^{2}}+\frac{{y}^{2}}{{2}^{2}}=1$

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

6. ${x}^{2}-{\left(y-2\right)}^{2}=1$

7. $2{x}^{2}-4x-\left({y}^{2}+4\right)=0$
$2{\left(x-2\right)}^{2}-{\left(y+2\right)}^{2}=4$
$\frac{{\left(x-2\right)}^{2}}{{\left(\sqrt{2}\right)}^{2}}-\frac{{\left(y+2\right)}^{2}}{{2}^{2}}=1$

コード

#!/usr/bin/env python3
from sympy import solve, plot
from sympy.abc import x, y

print('24.')

eqs = [
y ** 2 + y - x,
y ** 2 - 2 * x + 4,
2 * (x - 1) ** 2 + (y + 1) ** 2 - 2,
(x + 3) ** 2 / 16 - (y - 1) ** 2 / 9 - 1,
4 * x ** 2 + 9 * y ** 2 - 24 * x,
2 * x ** 2 + y ** 2 - 4 * x + 4 * y + 2,
x ** 2 - y ** 2 + 4 * y - 5,
2 * x ** 2 - y ** 2 - 4 * x - 4 * y
]

for i, eq in enumerate(eqs, 1):
ys = solve(eq, y)
p = plot(*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.save(f'sample24_{i}.png')
p.show()


% ./sample24.py
24.
%