2020年7月11日土曜日

数学 - Python - 放物線・だ円・双曲線 - 2次関数 - 放物線・だ円・双曲線 - 双曲線 - 焦点、漸近線、頂点、直角双曲線、方程式、距離の差、一定

1. $\frac{{x}^{2}}{{3}^{2}-{2}^{2}}-\frac{{y}^{2}}{{2}^{2}}=-1$
$\frac{{x}^{2}}{3}-\frac{{y}^{2}}{4}=-1$

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

3. ${x}^{2}-\frac{{y}^{2}}{\frac{1}{4}}=1$
${x}^{2}-4{y}^{2}=1$

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

5. $\frac{{x}^{2}}{9}-\frac{{y}^{2}}{9}=-1$

6. $\parallel \left(3,2\right)-\left(0,2\right)\parallel =\sqrt{{3}^{2}}=3$
$\parallel \left(3,2\right)-\left(0,-2\right)\parallel =\sqrt{{3}^{2}+{4}^{2}}=5$
$5-3=2$
$\frac{{x}^{2}}{{2}^{2}-{1}^{2}}-{y}^{2}=-1$
$\frac{{x}^{2}}{3}-{y}^{2}=-1$

コード

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

print('9.')

eqs = [x ** 2 / 3 - y ** 2 / 4 + 1,
x ** 2 - y ** 2 / 4 - 1,
x ** 2 - 4 * y ** 2 - 1,
x ** 2 / 4 - y ** 2 / 4 - 1,
x ** 2 / 9 - y ** 2 / 9 + 1,
x ** 2 / 3 - y ** 2 + 1]
ys = [(2, -2),
(2 * x, -2 * x),
(x / 2, -x / 2),
(x, -x),
(x, -x),
(2, -2)]
colors = ['red', 'green', 'blue', 'brown', 'orange',
'purple', 'pink', 'gray', 'skyblue', 'yellow']

for i, (eq, ys0) in enumerate(zip(eqs, ys), 1):
print(f'({i})')
ys1 = solve(eq, y)
p = plot(*ys1, *ys0,
(x, -10, 10),
ylim=(-10, 10),
legend=True,
show=False)
for o, color in zip(p, colors):
o.line_color = color
p.save(f'sample9_{i}.png')
p.show()


% ./sample9.py
9.
(1)
(2)
(3)
(4)
(5)
(6)
%