2020年7月1日水曜日

学習環境

代数への出発 (新装版 数学入門シリーズ) (松坂 和夫(著)、岩波書店)の第7章(不等式)、2(2次不等式)の問7の解答を求めてみる。



    1. x2-(3+a)y+3a>0(x-3)(x-a)>0
      a<3

      のとき不等式の解は

      x<a,3<x
      a>3

      のとき

      x<3,a<x
      a=3

      のとき、

      \{3}

    2. (x-3a)(x+2a)<0

      よって、解は

      a>0

      のとき

      -2a<x<3a
      a<0

      のとき

      3a<x<-2a
      a=0

      のとき解はない。

コード

#!/usr/bin/env python3
from sympy import pprint, symbols, sqrt, plot

print('7.')

a, x = symbols('a, x', real=True)
f = x ** 2 - (3 + a) * x + 3 * a
g = x ** 2 - a * x - 6 * a ** 2

fas = [2, 3, 4]
gas = [-1, 0, 1]

for i, (o, ts) in enumerate(zip([f, g], [fas, gas]), 1):
    print(f'({i})')
    p = plot(*[o.subs({a: t}) for t in ts],
             (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(f'sample7_{i}.png')

p.show()

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

% ./sample7.py
7.
(1)
(2)
%

0 コメント:

コメントを投稿