2020年3月22日日曜日

学習環境

解析入門 原書第3版 (S.ラング(著)、松坂 和夫(翻訳)、片山 孝次(翻訳)、岩波書店)の第Ⅵ部(多変数の関数)、第19章(多変数の関数)、1(グラフと等位線)の練習問題9の解答を求めてみる。


  1. x 2 4 + y 2 16 = c

    場合分け。

    c が零のとき

    x = 0 , y = 0

    c が正の場合、

    x 2 4 c + y 2 16 c = 1

    よって、 c が 正 の場合、楕円。

コード

#!/usr/bin/env python3
from sympy import symbols, plot, sqrt
from sympy.plotting import plot3d

print('9.')

x, y = symbols('x, y', real=True)
p = plot3d(x ** 2 / 4 + y ** 2 / 16, show=False)

p.xlabel = x
p.ylabel = y
p.show()
p.save('sample9.png')

p = plot(*[sign * sqrt(16 * c - 4 * x ** 2)
           for c in range(1, 4)
           for sign in [-1, 1]],
         (x, -10, 10),
         ylim=(-10, 10),
         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('sample9_1.png')

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

% ./sample9.py 
9.
%

0 コメント:

コメントを投稿