2020年7月11日土曜日

学習環境

新装版 数学読本3 (松坂 和夫(著)、岩波書店)の第12章(放物線・だ円・双曲線 - 2次関数)、12.1(放物線・だ円・双曲線)、双曲線の問9の解答を求めてみる。



    1. x 2 3 2 - 2 2 - y 2 2 2 = - 1
      x 2 3 - y 2 4 = - 1

    2. x 2 - y 2 2 2 = 1
      x 2 - y 2 4 = 1

    3. x 2 - y 2 1 4 = 1
      x 2 - 4 y 2 = 1

    4. x 2 4 - y 2 4 = 1

    5. x 2 9 - y 2 9 = - 1

    6. ( 3 , 2 ) - ( 0 , 2 ) = 3 2 = 3
      ( 3 , 2 ) - ( 0 , - 2 ) = 3 2 + 4 2 = 5
      5 - 3 = 2
      x 2 2 2 - 1 2 - y 2 = - 1
      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()

入出力結果(Zsh、PowerShell、Terminal、Jupyter(IPython))

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

0 コメント:

コメントを投稿