## 2020年7月22日水曜日

### 数学 - Python - 代数学 - 不等式 - 食塩の濃度

1. $0.05\le \frac{x}{100+x}\le 0.055$
$50\le \frac{1000x}{100+x}\le 55$
$10\left(100+x\right)\le 200x\le 11\left(100+x\right)$
$1000+10x\le 200x\le 1100+11x$
$\frac{1000}{190}\le x\le \frac{1100}{189}$
$\frac{100}{19}\le x\le \frac{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()


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