学習環境
- Surface、Surface ペン(端末)
- Windows 10 Pro (OS)
- Nebo(Windows アプリ)
- iPad Pro 10.5 + Apple Pencil
- MyScript Nebo - MyScript(iPad アプリ(iOS))
- 参考書籍
数学読本〈2〉簡単な関数/平面図形と式/指数関数・対数関数/三角関数 (松坂 和夫(著)、岩波書店)の第5章(関連しながら変化する世界 - 簡単な関数)、5.2(2次関数)、2次関数の最大・最小の問13の解答を求めてみる。
コード
Python 3
#!/usr/bin/env python3 from sympy import pprint, symbols, Rational, plot print('13.') x = symbols('x') intervals = [(2, 4), (-3, 1), (0, 4)] fs = [x ** 2 - 3 * x, -2 * x ** 2 - 4 * x + 5, x ** 2 / 2 - 3 * x + 6] ys_min = [-2, -1, Rational(3, 2)] ys_max = [4, 7, 6] p = plot(*[(f, (x, a, b)) for f, (a, b) in zip(fs, intervals)], *[(y, (x, a, b)) for y, (a, b) in zip(ys_min, intervals)], *[(y, (x, a, b)) for y, (a, b) in zip(ys_max, intervals)], show=False, legend=False) colors = ['red', 'green', 'blue', 'brown', 'orange', 'purple', 'pink', 'skyblue', 'gray', 'yellow'] l = list(zip(p[:3], colors)) + \ list(zip(p[3:6], colors)) + \ list(zip(p[6:], colors)) for o, color in l: o.line_color = color p.show() p.save('sample13.png')
入出力結果(cmd(コマンドプロンプト)、Terminal、Jupyter(IPython))
C:\Users\...>py sample13.py 13. C:\Users\...>
0 コメント:
コメントを投稿