## 2020年7月21日火曜日

### 数学 - Python - 放物線・だ円・双曲線 - 2次関数 - 2次曲線と直線 - だ円・双曲線と直線 - 双曲線と直線の共有点の個数、判別式

1. ${x}^{2}-{\left(2x+k\right)}^{2}=1$
$3{x}^{2}+2·2kx+{k}^{2}+1=0$
$\frac{D}{4}=4{k}^{2}-3\left({k}^{2}+1\right)={k}^{2}-3$

よって、問題の双曲線と直線の共有点の個数は

$|k|<\sqrt{3}$

のとき0個、

$|k|=\sqrt{3}$

とき1個、

$|k|>\sqrt{3}$

のとき2個。

2. ${x}^{2}-{\left(x+k\right)}^{2}=1$
$2kx+{k}^{2}+1=0$
$k=0$

のとき0個。

$k\ne 0$

のとき1個。

3. ${x}^{2}-{\left(\frac{1}{2}x+k\right)}^{2}=1$
$\frac{3}{4}{x}^{2}-kx-{k}^{2}-1=0$
$3{x}^{2}-4kx-4\left({k}^{2}+1\right)=0$
$\frac{D}{4}=4{k}^{2}+12\left({k}^{2}+1\right)=4\left(4{k}^{2}+3\right)>0$

2個。

コード

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

print('17.')

x, y = symbols('x, y', real=True)
eq = x ** 2 - y ** 2 - 1
ys = solve(eq, y)
p = plot(*ys,
*[2 * x + k
for k in [-1 - sqrt(3), -sqrt(3), 0, sqrt(3), sqrt(3) + 1]],
*[x + k for k in range(2)],
*[x / 2 + k for k in [-1, 1]],
(x, -5, 5),
ylim=(-5, 5),
legend=False,
show=False)

colors = ['red', 'green', 'blue', 'brown', 'orange',
'purple', 'pink', 'gray', 'skyblue', 'yellow']
for o, color in zip(p, colors):
o.line_color = color
print(o, color)
p.save('sample17.png')
p.show()


% ./sample17.py
17.
cartesian line: -sqrt(x**2 - 1) for x over (-5.0, 5.0) red
cartesian line: sqrt(x**2 - 1) for x over (-5.0, 5.0) green
cartesian line: 2*x - sqrt(3) - 1 for x over (-5.0, 5.0) blue
cartesian line: 2*x - sqrt(3) for x over (-5.0, 5.0) brown
cartesian line: 2*x for x over (-5.0, 5.0) orange
cartesian line: 2*x + sqrt(3) for x over (-5.0, 5.0) purple
cartesian line: 2*x + 1 + sqrt(3) for x over (-5.0, 5.0) pink
cartesian line: x for x over (-5.0, 5.0) gray
cartesian line: x + 1 for x over (-5.0, 5.0) skyblue
cartesian line: x/2 - 1 for x over (-5.0, 5.0) yellow
%