## 2019年2月2日土曜日

### 数学 - Python - 大小関係を見る - 不等式 – 不等式の解法 – 2次不等式(解)

1. $x<-\frac{3}{2},2

2. $x<-4,\frac{5}{2}

3. $\begin{array}{}\left(x-3\right)\left(x-4\right)<0\\ 3

4. $\begin{array}{}\left(x-6\right)\left(x+4\right)\le 0\\ -4\le x\le 6\end{array}$

5. $\begin{array}{}x=2±\sqrt{4-2}\\ =2±\sqrt{2}\\ x\le 2-\sqrt{2},2+\sqrt{2}\le x\end{array}$

6. $\begin{array}{}x=\frac{-1±\sqrt{1+80}}{2\left(-2\right)}\\ =\frac{-1±9}{-4}\\ =-2,\frac{5}{2}\\ -2

7. $\begin{array}{}{\left(x+4\right)}^{2}>0\\ \text{ℝ}-\left\{-4\right\}\end{array}$

8. $x=0$

9. $\begin{array}{}D=1-4<0\\ \text{ℝ}\end{array}$

10. $\begin{array}{}4{x}^{2}-6x+5<0\\ \frac{D}{4}=9-20<0\\ \varphi \end{array}$

11. $\begin{array}{}10{x}^{2}-5x+2>0\\ D=25-80<0\\ \text{ℝ}\end{array}$

12. $\begin{array}{}{x}^{2}+2x-4\le 0\\ \frac{D}{4}=1+4=5\\ x=-1±\sqrt{5}\\ -1-\sqrt{5}\le x\le -1+\sqrt{5}\end{array}$

コード

Python 3

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

print('9.')

x = symbols('x')
ts = [(x - 2) * (2 * x + 3) > 0,
(4 + x) * (5 - 2 * x) <= 0,
x ** 2 - 7 * x + 12 < 0,
x ** 2 - 2 * x - 24 <= 0,
x ** 2 - 4 * x + 2 >= 0,
10 + x - 2 * x ** 2 > 0,
x ** 2 + 8 * x + 16 > 0,
-2 * x ** 2 >= 0,
x ** 2 - x + 1 > 0,
4 * x ** 2 + 5 < 6 * x,
5 * x - 10 * x ** 2 < 2,
2 * x ** 2 + 3 * x - 4 <= x ** 2 + x]

for i, t in enumerate(ts, 1):
print(f'({i})')
pprint(reduce_inequalities(t))
print()

p = plot(2 * x ** 2 + 3 * x - 4, x ** 2 + x, legend=True, show=False)
colors = ['red', 'green']
for i, _ in enumerate(p):
p[i].line_color = colors[i]

p.save('sample9.png')


$python3 sample9.py 9. (1) (-∞ < x ∧ x < -3/2) ∨ (2 < x ∧ x < ∞) (2) (5/2 ≤ x ∧ x < ∞) ∨ (x ≤ -4 ∧ -∞ < x) (3) 3 < x ∧ x < 4 (4) -4 ≤ x ∧ x ≤ 6 (5) (x ≤ -√2 + 2 ∧ -∞ < x) ∨ (√2 + 2 ≤ x ∧ x < ∞) (6) -2 < x ∧ x < 5/2 (7) x > -∞ ∧ x < ∞ ∧ x ≠ -4 (8) x = 0 (9) -∞ < x ∧ x < ∞ (10) False (11) -∞ < x ∧ x < ∞ (12) x ≤ -1 + √5 ∧ -√5 - 1 ≤ x$