## 2020年8月3日月曜日

### 数学 - Python - 放物線・だ円・双曲線 - 2次関数 - 2次曲線の平行移動と回転 - 2次曲線の回転 - 三角関数(正弦と余弦)、加法定理

1. $x\mathrm{cos}4{5}^{\circ }+y\mathrm{sin}4{5}^{\circ }=\frac{x+y}{\sqrt{2}}$
$-x\mathrm{sin}4{5}^{\circ }+y\mathrm{cos}4{5}^{\circ }=\frac{-x+y}{\sqrt{2}}$
$3·\frac{{\left(x+y\right)}^{2}}{2}-2·\frac{x+y}{\sqrt{2}}·\frac{-x+y}{\sqrt{2}}+3·\frac{{\left(-x+y\right)}^{2}}{2}=2$
$3{x}^{2}+3{y}^{2}+{x}^{2}-{y}^{2}=2$
$4{x}^{2}+2{y}^{2}=2$
$\frac{{x}^{2}}{\frac{1}{2}}+{y}^{2}=1$

だ円を表す曲線。

2. $x\mathrm{cos}3{0}^{\circ }+y\mathrm{sin}3{0}^{\circ }=\frac{\sqrt{3}x+y}{2}$
$-x\mathrm{sin}3{0}^{\circ }+y\mathrm{sin}3{0}^{\circ }=\frac{-x+\sqrt{3}y}{2}$
$2·{\left(\frac{-x+\sqrt{3}y}{2}\right)}^{2}+2\sqrt{3}·\frac{\sqrt{3}x+y}{2}·\frac{-x+\sqrt{3}y}{2}=-1$
$\frac{{x}^{2}-2\sqrt{3}xy+3{y}^{2}}{2}+\frac{\sqrt{3}}{2}\left(-\sqrt{3}{x}^{2}+\sqrt{3}{y}^{2}+2xy\right)=-1$
$\frac{1}{2}\left({x}^{2}-2\sqrt{3}xy+3{y}^{2}-3{x}^{2}+3{y}^{2}+2\sqrt{3}xy\right)=-1$
$\frac{1}{2}\left(-2{x}^{2}+6{y}^{2}\right)=-1$
${x}^{2}-3{y}^{2}=1$

双曲線。

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

放物線。

4. $x\mathrm{cos}\left(-4{5}^{\circ }\right)+y\mathrm{sin}\left(-4{5}^{\circ }\right)=\frac{x-y}{\sqrt{2}}$
$-x\mathrm{sin}\left(-4{5}^{\circ }\right)+y\mathrm{cos}\left(-4{5}^{\circ }\right)=\frac{x+y}{\sqrt{2}}$
$\frac{{\left(x-y\right)}^{2}}{2}-\frac{{x}^{2}-{y}^{2}}{2}+\frac{{\left(x+y\right)}^{2}}{2}=3$
${x}^{2}+{y}^{2}-\frac{{x}^{2}-{y}^{2}}{2}=3$
$\frac{{x}^{2}}{2}+\frac{3{y}^{2}}{2}=3$

だ円。

$x\mathrm{cos}6{0}^{\circ }+y\mathrm{sin}6{0}^{\circ }=\frac{x+\sqrt{3}y}{2}$
$-x\mathrm{sin}6{0}^{\circ }+y\mathrm{cos}6{0}^{\circ }=\frac{-\sqrt{3}x+y}{2}$
${\left(\frac{\sqrt{3}x+3y}{2}+\frac{-\sqrt{3}x+y}{2}\right)}^{2}=4\left(\frac{x+\sqrt{3}y}{2}+\frac{3x-\sqrt{3}y}{2}\right)$
$4{y}^{2}=8x$
${y}^{2}=2x$

放物線。

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

双曲線。

コード

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

print('26.')

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

for i, (eq1, eq2) in enumerate(zip(eqs1, eqs2), 1):
ys1 = solve(eq1, y)
ys2 = solve(eq2, y)
p = plot(*ys1,
*ys2,
(x, -5, 5),
ylim=(-5, 5),
legend=True,
show=False)

for o, color in zip(p, colors):
o.line_color = color
p.save(f'sample26_{i}.png')
p.show()


% ./sample26.py
26.
%