読書環境
- Kindle(白黒)
- iPad Pro 10.5 + Kindle(カラー)
- 紙
学習環境
- Surface Go、タイプ カバー、ペン(端末)
- Windows 10 Pro (OS)
- Nebo(Windows アプリ)
- iPad Pro + Apple Pencil
- MyScript Nebo - MyScript(iPad アプリ(iOS))
- 参考書籍
開発環境
- macOS Mojave - Apple (OS)
- Emacs (Text Editor)
- Windows 10 Pro (OS)
- Visual Studio Code (Text Editor)
- Python 3.7 (プログラミング言語)
- SymPy (パッケージ)
コード
Python 3
#!/usr/bin/env python3
from sympy import pprint, symbols, Derivative, cos, plot
x, dx = symbols('x, △x')
def d(f):
return ((f.subs({x: x + dx}) - f) / dx).limit(dx, 0)
fs = [x ** 2, cos(x)]
for i, f in enumerate(fs, 1):
print(f'({i})')
l = Derivative(f, x, 1).doit()
for t in [d(f), l]:
pprint(t)
print()
print()
p = plot(*fs, ylim=(-10, 10), legend=True, show=False)
colors = ['red', 'green']
for i, color in enumerate(colors):
p[i].line_color = color
p.save('sample1.png')
入出力結果(cmd(コマンドプロンプト)、Terminal、Jupyter(IPython))
$ python3 sample1.py (1) 2⋅x 2⋅x (2) -sin(x) -sin(x) $
0 コメント:
コメントを投稿