学習環境
- Surface 3 (4G LTE)、Surface 3 タイプ カバー、Surface ペン(端末)
- Windows 10 Pro (OS)
- 数式入力ソフト(TeX, MathML): MathType
- MathML対応ブラウザ: Firefox、Safari
- MathML非対応ブラウザ(Internet Explorer, Google Chrome...)用JavaScript Library: MathJax
- Pythonからはじめる数学入門(参考書籍)
解析入門〈1〉(松坂 和夫(著)、岩波書店)の第5章(各種の初等関数)、5.4(三角関数(続き)、逆三角関数)、問題4、5.を取り組んでみる。
コード(Emacs)
Python 3
#!/usr/bin/env python3 # -*- coding: utf-8 -*- from sympy import Symbol, symbols, Derivative, sqrt, sin, cos, exp, pi, log, solve, pprint print('4') n = Symbol('n', integer=True, positive=True) x = Symbol('x') expr1 = exp(x) * sin(x) expr2 = sqrt(2) ** n * exp(x) * sin(x + n * pi / 4) pprint(expr1) pprint(expr2) for i in range(10): print('n = {}'.format(i + 1)) d = Derivative(expr1, x, i).doit() pprint(d) expr = expr2.subs({n: i}) pprint(expr) print((d - expr).expand() == 0) print('5.') a, b = symbols('a b') x = Symbol('x', nonzero=True) f = a * cos(log(x)) + b * sin(log(x)) pprint(f) print('(a)') f1 = Derivative(f, x, 1).doit() f2 = Derivative(f, x, 2).doit() pprint(f1) pprint(f2) expr = x ** 2 * f2 + x * f1 + f pprint(expr) print(expr.expand() == 0) print('(b)') for i in range(10): print('n = {0}'.format(i + 1)) expr = x**n * Derivative(f, x, i).doit() pprint(expr)
入出力結果(Terminal, IPython)
$ ./sample4.py 4 x ℯ ⋅sin(x) n ─ 2 x ⎛π⋅n ⎞ 2 ⋅ℯ ⋅sin⎜─── + x⎟ ⎝ 4 ⎠ n = 1 x ℯ ⋅sin(x) x ℯ ⋅sin(x) True n = 2 x x ℯ ⋅sin(x) + ℯ ⋅cos(x) x ⎛ π⎞ √2⋅ℯ ⋅sin⎜x + ─⎟ ⎝ 4⎠ False n = 3 x 2⋅ℯ ⋅cos(x) x 2⋅ℯ ⋅cos(x) True n = 4 x 2⋅(-sin(x) + cos(x))⋅ℯ x ⎛ π⎞ 2⋅√2⋅ℯ ⋅cos⎜x + ─⎟ ⎝ 4⎠ False n = 5 x -4⋅ℯ ⋅sin(x) x -4⋅ℯ ⋅sin(x) True n = 6 x -4⋅(sin(x) + cos(x))⋅ℯ x ⎛ π⎞ -4⋅√2⋅ℯ ⋅sin⎜x + ─⎟ ⎝ 4⎠ False n = 7 x -8⋅ℯ ⋅cos(x) x -8⋅ℯ ⋅cos(x) True n = 8 x 8⋅(sin(x) - cos(x))⋅ℯ x ⎛ π⎞ -8⋅√2⋅ℯ ⋅cos⎜x + ─⎟ ⎝ 4⎠ False n = 9 x 16⋅ℯ ⋅sin(x) x 16⋅ℯ ⋅sin(x) True n = 10 x 16⋅(sin(x) + cos(x))⋅ℯ x ⎛ π⎞ 16⋅√2⋅ℯ ⋅sin⎜x + ─⎟ ⎝ 4⎠ False 5. a⋅cos(log(x)) + b⋅sin(log(x)) (a) a⋅sin(log(x)) b⋅cos(log(x)) - ───────────── + ───────────── x x a⋅sin(log(x)) - a⋅cos(log(x)) - b⋅sin(log(x)) - b⋅cos(log(x)) ───────────────────────────────────────────────────────────── 2 x ⎛ a⋅sin(log(x)) b⋅cos(log(x))⎞ a⋅sin(log(x)) - b⋅cos(log(x)) + x⋅⎜- ───────────── + ─────────────⎟ ⎝ x x ⎠ True (b) n = 1 n x ⋅(a⋅cos(log(x)) + b⋅sin(log(x))) n = 2 n ⎛ a⋅sin(log(x)) b⋅cos(log(x))⎞ x ⋅⎜- ───────────── + ─────────────⎟ ⎝ x x ⎠ n = 3 n x ⋅(a⋅sin(log(x)) - a⋅cos(log(x)) - b⋅sin(log(x)) - b⋅cos(log(x))) ────────────────────────────────────────────────────────────────── 2 x n = 4 n x ⋅(-a⋅sin(log(x)) + 3⋅a⋅cos(log(x)) + 3⋅b⋅sin(log(x)) + b⋅cos(log(x))) ─────────────────────────────────────────────────────────────────────── 3 x n = 5 n -10⋅x ⋅(a⋅cos(log(x)) + b⋅sin(log(x))) ─────────────────────────────────────── 4 x n = 6 n 10⋅x ⋅(a⋅sin(log(x)) + 4⋅a⋅cos(log(x)) + 4⋅b⋅sin(log(x)) - b⋅cos(log(x))) ───────────────────────────────────────────────────────────────────────── 5 x n = 7 n 10⋅x ⋅(-9⋅a⋅sin(log(x)) - 19⋅a⋅cos(log(x)) - 19⋅b⋅sin(log(x)) + 9⋅b⋅cos(log(x)) ─────────────────────────────────────────────────────────────────────────────── 6 x ) ─ n = 8 n 10⋅x ⋅(73⋅a⋅sin(log(x)) + 105⋅a⋅cos(log(x)) + 105⋅b⋅sin(log(x)) - 73⋅b⋅cos(log( ─────────────────────────────────────────────────────────────────────────────── 7 x x))) ──── n = 9 n 20⋅x ⋅(-308⋅a⋅sin(log(x)) - 331⋅a⋅cos(log(x)) - 331⋅b⋅sin(log(x)) + 308⋅b⋅cos(l ─────────────────────────────────────────────────────────────────────────────── 8 x og(x))) ─────── n = 10 n 1300⋅x ⋅(43⋅a⋅sin(log(x)) + 36⋅a⋅cos(log(x)) + 36⋅b⋅sin(log(x)) - 43⋅b⋅cos(log( ─────────────────────────────────────────────────────────────────────────────── 9 x x))) ──── $
0 コメント:
コメントを投稿