## 2019年4月28日日曜日

### 数学 - Python - 関連しながら変化する世界 - 簡単な関数 - 2次関数 - 2次関数のグラフと2次不等式(判別式、正負、上に凸、下に凸)

1. $\begin{array}{l}D={\left(-3m\right)}^{2}-4·4·\left(2m+1\right)\\ =9{m}^{2}-32m-16\\ 9{m}^{2}-32m-16<0\\ \left(m-4\right)\left(9m+4\right)<0\\ -\frac{4}{9}

2. $\begin{array}{l}m>0\\ \frac{D}{4}=4-m\left(m-3\right)\\ =-{m}^{2}+3m+4\\ =-\left(m+1\right)\left(m-4\right)\\ D\le 0\\ m\le -1,4\le m\\ 4\le m\end{array}$

3. $\begin{array}{l}m<0\\ D={\left(m-1\right)}^{2}-4m\left(m-1\right)<0\\ -3{m}^{2}+2m+1<0\\ 3{m}^{2}-2m-1>0\\ \left(m-1\right)\left(3m+1\right)>0\\ m<-\frac{1}{3},1

コード

Python 3

#!/usr/bin/env python3
from sympy import pprint, symbols, plot, sqrt, Rational

print('19.')

x, m = symbols('x, m')
fs = [(4 * x ** 2 - 3 * m * x + (2 * m + 1)).subs({m: m0})
for m0 in [-Rational(4, 9), 0, 4]]
gs = [(m * x ** 2 - 4 * x + (m - 3)).subs({m: m0})
for m0 in [3, 4]]

hs = [(m * x ** 2 + (m - 1) * x + (m - 1)).subs({m: m0})
for m0 in [-Rational(1, 3), -Rational(2, 3)]]

p = plot(*fs,
*gs,
*hs,
(x, -10, 10),
ylim=(-10, 10),
show=False,
legend=True)

colors = ['red', 'green', 'blue', 'brown', 'orange',
'purple', 'gray', 'skyblue', 'yellow']
for o, color in zip(p, colors):
o.line_color = color

p.show()
p.save('sample19.png')


C:\Users\...>py sample19.py
19.

C:\Users\...>