学習環境
- Surface
- Windows 10 Pro (OS)
- Nebo(Windows アプリ)
- iPad
- MyScript Nebo - MyScript(iPad アプリ(iOS))
- 参考書籍
代数への出発 (新装版 数学入門シリーズ) (松坂 和夫(著)、岩波書店)の第7章(不等式)、2(2次不等式)の問10の解答を求めてみる。
コード
#!/usr/bin/env python3
from sympy import pprint, symbols, plot, sqrt, Rational
from sympy.solvers.inequalities import reduce_inequalities
from sympy.abc import k, x
print('10.')
f = x ** 2 - 3 * x - 10
g = x ** 2 - 2 * x - 40
for i, d in enumerate([(k + 3) ** 2 - 4, (k - 1) ** 2 - k], 1):
print(f'({i})')
pprint(reduce_inequalities([d > 0]))
p = plot(*[x ** 2 + (k + 3) * x + 1 for k in [-6, -5, -2, -1, 2]],
*[x ** 2 - 2 * (k - 1) * x + k for k in [(3 - sqrt(5)) / 2 - 1,
(3 - sqrt(5)) / 2,
Rational(3, 2),
(3 + sqrt(5)) / 2,
(3 + sqrt(5)) / 2 + 1]],
(x, -10, 10),
ylim=(-10, 10),
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('sample10.png')
入出力結果(Zsh、PowerShell、Terminal、Jupyter(IPython))
% ./sample10.py
10.
(1)
(-∞ < k ∧ k < -5) ∨ (-1 < k ∧ k < ∞)
(2)
⎛ 3 √5⎞ ⎛ √5 3 ⎞
⎜-∞ < k ∧ k < ─ - ──⎟ ∨ ⎜k < ∞ ∧ ── + ─ < k⎟
⎝ 2 2 ⎠ ⎝ 2 2 ⎠
cartesian line: x**2 - 3*x + 1 for x over (-10.0, 10.0) red
cartesian line: x**2 - 2*x + 1 for x over (-10.0, 10.0) green
cartesian line: x**2 + x + 1 for x over (-10.0, 10.0) blue
cartesian line: x**2 + 2*x + 1 for x over (-10.0, 10.0) brown
cartesian line: x**2 + 5*x + 1 for x over (-10.0, 10.0) orange
cartesian line: x**2 - x*(-sqrt(5) - 1) - sqrt(5)/2 + 1/2 for x over (-10.0, 10.0) purple
cartesian line: x**2 - x*(1 - sqrt(5)) - sqrt(5)/2 + 3/2 for x over (-10.0, 10.0) pink
cartesian line: x**2 - x + 3/2 for x over (-10.0, 10.0) gray
cartesian line: x**2 - x*(1 + sqrt(5)) + sqrt(5)/2 + 3/2 for x over (-10.0, 10.0) skyblue
cartesian line: x**2 - x*(sqrt(5) + 3) + sqrt(5)/2 + 5/2 for x over (-10.0, 10.0) yellow
%
0 コメント:
コメントを投稿