学習環境
- Surface
- Windows 10 Pro (OS)
- Nebo(Windows アプリ)
- iPad
- MyScript Nebo - MyScript(iPad アプリ(iOS))
- 参考書籍
代数への出発 (新装版 数学入門シリーズ) (松坂 和夫(著)、岩波書店)の第7章(不等式)の練習問題8.の解答を求めてみる。
よって 2つの2 次方程式が実解をもつ k の範囲は
コード
#!/usr/bin/env python3
from sympy import plot, sqrt, pprint
from sympy.abc import x, k
from sympy.solvers.inequalities import reduce_inequalities
print('8.')
d1 = 4 ** 2 - 4 * k
d2 = k ** 2 - 4 * (k + 1)
pprint(reduce_inequalities([d >= 0 for d in [d1, d2]]))
f = x ** 2 + 4 * x + k
g = x ** 2 + k * x + (k + 1)
ks = [-2 * sqrt(2), 2 - 2 * sqrt(2), 2, 2 + 2 * sqrt(2), 4]
p = plot(
*[f.subs({k: k0}) for k0 in ks],
*[g.subs({k: k0}) for k0 in ks],
(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.save('sample8.png')
p.show()
入出力結果(Zsh、PowerShell、Terminal、Jupyter(IPython))
% ./sample8.py
8.
k ≤ 2 - 2⋅√2 ∧ -∞ < k
cartesian line: x**2 + 4*x - 2*sqrt(2) for x over (-10.0, 10.0) red
cartesian line: x**2 + 4*x - 2*sqrt(2) + 2 for x over (-10.0, 10.0) green
cartesian line: x**2 + 4*x + 2 for x over (-10.0, 10.0) blue
cartesian line: x**2 + 4*x + 2 + 2*sqrt(2) for x over (-10.0, 10.0) brown
cartesian line: x**2 + 4*x + 4 for x over (-10.0, 10.0) orange
cartesian line: x**2 - 2*sqrt(2)*x - 2*sqrt(2) + 1 for x over (-10.0, 10.0) purple
cartesian line: x**2 + x*(2 - 2*sqrt(2)) - 2*sqrt(2) + 3 for x over (-10.0, 10.0) pink
cartesian line: x**2 + 2*x + 3 for x over (-10.0, 10.0) gray
cartesian line: x**2 + x*(2 + 2*sqrt(2)) + 2*sqrt(2) + 3 for x over (-10.0, 10.0) skyblue
cartesian line: x**2 + 4*x + 5 for x over (-10.0, 10.0) yellow
%
0 コメント:
コメントを投稿