2020年7月22日水曜日

学習環境

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


  1. 0.05 x 100 + x 0.055
    50 1000 x 100 + x 55
    10 ( 100 + x ) 200 x 11 ( 100 + x )
    1000 + 10 x 200 x 1100 + 11 x
    1000 190 x 1100 189
    100 19 x 1100 189

コード

#!/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 コメント:

コメントを投稿