## 2019年9月6日金曜日

### 数学 - Python - 急速・緩慢に変化する関係 - 指数関数・対数関数 - 指数関数と対数関数 - 指数関数の性質 - 不等式の解、増加関数、減少関数

1. $\begin{array}{l}{4}^{x}<32\\ {2}^{2x}<{2}^{5}\\ 2x<5\\ x<\frac{5}{2}\end{array}$

2. $\begin{array}{l}0.{2}^{x}\ge 1\\ {\left(\frac{1}{5}\right)}^{x}\ge 1\\ {5}^{-x}\ge {5}^{0}\\ -x\ge 0\\ x\le 0\end{array}$

3. $\begin{array}{l}{\left(\frac{1}{3}\right)}^{x}\le 27\\ {3}^{-x}\le {3}^{3}\\ -x\le 3\\ x\ge -3\end{array}$

4. $\begin{array}{l}0.125<0.{5}^{x}<1\\ {\left(0.5\right)}^{3}<0.{5}^{x}<0.{5}^{0}\\ 0

コード

Python 3

#!/usr/bin/env python3
from sympy import pprint, symbols, sqrt, root, Rational, plot
from sympy.solvers.inequalities import reduce_inequalities

print('12.')

x = symbols('x')
inequalities = [4 ** x > 32,
0.2 ** x >= 1,
Rational(1, 3) ** x <= 27,
(0.125 < 0.5 ** x, 0.5 ** x < 1)]
for i, inequality in enumerate(inequalities, 1):
print(f'({i})')
try:
pprint(reduce_inequalities(inequality, x).expand())
except Exception as err:
pprint(reduce_inequalities(inequality, x))
print()

fss = [((4 ** x, 32), (0, 35)),
((0.2 ** x, 1), (0, 2)),
((Rational(1, 3) ** x, 27), (0, 30)),
((0.125, 0.5 ** x, 1), (0, 2))]
for i, (fs, (y1, y2)) in enumerate(fss, 1):
p = plot(*fs,
ylim=(y1, y2),
legend=True,
show=False)
colors = ['red', 'green', 'blue', 'brown', 'orange',
'purple', 'pink', 'gray', 'skyblue', 'yellow']

for s, color in zip(p, colors):
s.line_color = color

p.show()
p.save(f'sample12_{i}.png')


C:\Users\...>py sample12.py
12.
(1)
5/2 < x

(2)
x ≤ 0

(3)
-3 ≤ x

(4)
0 < x ∧ x < 3.0

C:\Users\...>