#!/usr/bin/env python3from sympy import pprint, symbols, sin, cos, Derivative, Function
r, a, b = symbols('r, a, b', nonzero=True)
x = r * sin(a) * cos(b)
y = r * sin(a) * sin(b)
z = r * cos(b)
g = Function('g')(r, a, b)
expr = Derivative(g, r, 1) ** 2 + (1 / r * Derivative(g, a, 1)
) ** 2 + (1 / (r * sin(a)) * Derivative(g, b, 1)) ** 2
for t in [expr, expr.doit()]:
pprint(t)
print()
入出力結果(Terminal, Jupyter(IPython))
$ ./sample11.py
2 2
⎛∂ ⎞ ⎛∂ ⎞
2 ⎜──(g(r, a, b))⎟ ⎜──(g(r, a, b))⎟
⎛∂ ⎞ ⎝∂a ⎠ ⎝∂b ⎠
⎜──(g(r, a, b))⎟ + ───────────────── + ─────────────────
⎝∂r ⎠ 2 2 2
r r ⋅sin (a)
2 2
⎛∂ ⎞ ⎛∂ ⎞
2 ⎜──(g(r, a, b))⎟ ⎜──(g(r, a, b))⎟
⎛∂ ⎞ ⎝∂a ⎠ ⎝∂b ⎠
⎜──(g(r, a, b))⎟ + ───────────────── + ─────────────────
⎝∂r ⎠ 2 2 2
r r ⋅sin (a)
$
0 コメント:
コメントを投稿