2020年6月29日月曜日

学習環境

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



    1. y=x2=14·14x2

      よって焦点、準線はそれぞれ

      (0,14)y=-14

    2. y=112x2=14·3x2(0,3)y=-3

    3. y=-12x2=14·(-12)x2(0,-12)y=12

    4. y2=4x=4·1x(1,0)x=-1

    5. y2=4(-14)x(-14,0)x=14

    6. y2=4·2x(2,0)x=-2

コード

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

print('2.')

ts = [(x ** 2, -Rational(1, 4)),
      (x ** 2 / 12, -3),
      (-x ** 2 / 2, Rational(1, 2))] + \
    [[s * sqrt(y) for s in [-1, 1]]
     for y in [4 * x, -x, 8 * x]]
for i, t in enumerate(ts, 1):
    print(f'({i})')
    p = plot(*t,
             (x, -5, 5),
             ylim=(-5, 5),
             legend=True,
             show=False)
    colors = ['red', 'green', 'blue', 'brown', 'orange',
              'purple', 'pink', 'gray', 'skyblue', 'yellow']
    for o, color in zip(p, colors):
        o.line_color = color
    p.save(f'sample2_{i}.png')
p.show()

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

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

0 コメント:

コメントを投稿