2020年6月20日土曜日

学習環境

代数への出発 (新装版 数学入門シリーズ) (松坂 和夫(著)、岩波書店)の第6章(1次方程式、2次方程式)、練習問題10の解答を求めてみる。



    1. x = 1 - 2 y
      x 2 + y 2 = ( 1 - 2 y ) 2 + y 2 = 5 y 2 - 4 y + 1 = 5 ( y - 2 5 ) 2 - 4 5 + 1 = 5 ( y - 2 5 ) 2 + 1 5

      よって最小値は

      1 5

    2. x 0 , y 0

      のとき、

      0 y 1 2

      よって求める最大値は

      y = 0

      のときで、

      1

コード

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

print('10.')

y = (1 - 2 * x) ** 2 + x ** 2

p = plot(*[(o, (x, -1, 1)) for o in [y, Rational(1, 5)]],
         *[(o, (x, 0, Rational(1, 2))) for o in [y, 1]],
         ylim=(0, 2),
         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.show()
p.save('sample10.png')

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

% ./sample10.py
10.
%

0 コメント:

コメントを投稿