## 2019年7月21日日曜日

### 数学 - Python - 図形と数や式の関係 - 平面図形と式 - 円と軌跡 - 円の接線 - 傾き、直線の方程式

1. $\begin{array}{l}y=\frac{1}{3}x±\sqrt{10}\sqrt{\frac{1}{9}+1}\\ =\frac{1}{3}x±\sqrt{10}\sqrt{\frac{10}{9}}\\ =\frac{1}{3}x±\frac{10}{3}\\ x-3y±10=0\end{array}$

2. $\begin{array}{l}y=-x±\sqrt{10}\sqrt{1+1}\\ =-x±2\sqrt{5}\\ x+y±2\sqrt{5}=0\end{array}$

コード

Python 3

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

print('26.')

m, x = symbols('m, x', real=True)
y1 = m * x + sqrt(10) * sqrt(m ** 2 + 1)
y2 = m * x - sqrt(10) * sqrt(m ** 2 + 1)
ms = [Rational(1, 3), -1]
ys = []
for i, m0 in enumerate(ms, 1):
print(f'({i})')
for y0 in [y1, y2]:
t = y0.subs({m: m0})
ys.append(t)
pprint(t)
print()

colors = ['red', 'green', 'blue', 'brown', 'orange',
'purple', 'pink', 'gray', 'skyblue', 'yellow']

p = plot((-sqrt(10 - x ** 2), (x, -sqrt(9.9), sqrt(9.9))),
(sqrt(10 - x ** 2), (x, -sqrt(9.9), sqrt(9.9))),
*[(y0, (x, -10, 10)) for y0 in ys],
ylim=(-10, 10),
legend=True,
show=False)

for s, color in zip(p, colors):
s.line_color = color

p.show()
p.save('sample26.png')


C:\Users\...>py sample26.py
26.
(1)
x   10
─ + ──
3   3

x   10
─ - ──
3   3

(2)
-x + 2⋅√5

-x - 2⋅√5

C:\Users\...>