## 2020年7月6日月曜日

### 数学 - Python - 代数学 - 不等式 - 2次不等式 - 2次方程式、判別式、実数海をもつ場合、正のみの場合、正と負の場合、y軸、頂点、交点

1. $\frac{D}{4}={\left(2m-1\right)}^{2}-\left(5{m}^{2}-4\right)=-{m}^{2}-4m+5$

実数解をもつ場合、

$-{m}^{2}-4m+5\ge 0$
${m}^{2}+4m-5\le 0$
$\left(m-1\right)\left(m+5\right)\le 0$
$-5\le m\le 1$

2. ${x}^{2}+2\left(2m-1\right)x+5{m}^{2}-4$
$={\left(x+\left(2m-1\right)\right)}^{2}-{m}^{2}-4m+5$

実数解が正のみの場合、

$\left\{\begin{array}{l}-5\le m\le 1\\ -\left(2m-1\right)>0\\ 5{m}^{2}-4>0\end{array}$
$m<\frac{1}{2}$
${m}^{2}>\frac{4}{5}$
$m<-\frac{2}{\sqrt{5}},\frac{2}{\sqrt{5}}
$-5\le m<-\frac{2}{\sqrt{5}}$

3. $\left\{\begin{array}{l}-5\le m\le 1\\ 5{m}^{2}-4<0\end{array}$
${m}^{2}<\frac{4}{5}$
$-\frac{2}{\sqrt{5}}

コード

#!/usr/bin/env python3
from sympy import plot, sqrt
from sympy.abc import m, x

print('12.')

f = x ** 2 + 2 * (2 * m - 1) * x + 5 * m ** 2 - 4

p = plot(*[f.subs({m: m0})
for m0 in [-6, -5, -2 / sqrt(5), 0, 2 / sqrt(5), 1, 2]],
(x, -20, 20),
ylim=(-20, 20),
legend=False,
show=False)

colors = ['red', 'green', 'blue', 'brown', 'orange',
'purple', 'pink', 'gray', 'skyblue', 'yellow']

for o, color in zip(p, colors):
o.line_color = color
print(o, color)
p.show()
p.save('sample12.png')


% ./sample12.py -v
12.
cartesian line: x**2 - 26*x + 176 for x over (-20.0, 20.0) red
cartesian line: x**2 - 22*x + 121 for x over (-20.0, 20.0) green
cartesian line: x**2 + x*(-8*sqrt(5)/5 - 2) for x over (-20.0, 20.0) blue
cartesian line: x**2 - 2*x - 4 for x over (-20.0, 20.0) brown
cartesian line: x**2 + x*(-2 + 8*sqrt(5)/5) for x over (-20.0, 20.0) orange
cartesian line: x**2 + 2*x + 1 for x over (-20.0, 20.0) purple
cartesian line: x**2 + 6*x + 16 for x over (-20.0, 20.0) pink
%