2020年7月22日水曜日

学習環境

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


  1. 0.05x100+x0.055
    501000x100+x55
    10(100+x)200x11(100+x)
    1000+10x200x1100+11x
    1000190x1100189
    10019x1100189

コード

#!/usr/bin/env python3
from sympy import Rational, pprint, plot
from sympy.abc import x
from sympy.solvers.inequalities import reduce_inequalities

print('2.')

f = Rational(5, 100)
g = x / (100 + x)
h = Rational(55, 1000)
pprint(reduce_inequalities([f <= g, g <= h], x))

p = plot(f * 100, g * 100, h * 100,
         (x, 0, 10),
         ylim=(0, 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('sample2.png')
p.show()

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

% ./sample2.py
2.
    1100   ⎛⎛100            ⎞                      ⎞           
x ≤ ──── ∧ ⎜⎜─── ≤ x ∧ x < ∞⎟ ∨ (-∞ < x ∧ x < -100)⎟ ∧ -100 < x
    189    ⎝⎝ 19            ⎠                      ⎠           
%

0 コメント:

コメントを投稿