## 2018年2月9日金曜日

### 数学 - Python - 解析学 - 多変数の関数 - 高次偏導関数、テイラーの定理(二階微分の和、距離、平方根)

1. $\begin{array}{}\frac{\partial f}{\partial {x}_{i}}\\ =g\text{'}\left(r\right)·\frac{1}{2}{\left(\sum _{k=1}^{n}{x}_{k}^{2}\right)}^{-\frac{1}{2}}·2{x}_{i}\\ =\frac{g\text{'}\left(r\right)}{r}{x}_{i}\end{array}$
$\begin{array}{}\frac{{\partial }^{2}f}{\partial {x}_{i}^{2}}\\ =\frac{g\text{'}\text{'}\left(r\right)r-g\text{'}\left(r\right)}{{r}^{2}}·\frac{{x}_{i}^{2}}{r}+\frac{g\text{'}\left(r\right)}{r}\end{array}$

よって、

$\begin{array}{}\sum _{i=1}^{n}\frac{{\partial }^{2}f}{\partial {x}_{i}}\\ =\frac{g\text{'}\text{'}\left(r\right)r-g\text{'}\left(r\right)}{{r}^{2}}·\frac{1}{r}\sum _{i=1}^{n}{x}_{i}^{2}+\frac{n}{r}g\text{'}\left(r\right)\\ =\frac{g\text{'}\text{'}\left(r\right)r-g\text{'}\left(r\right)}{{r}^{2}}·\frac{1}{r}·{r}^{2}+\frac{n}{r}g\text{'}\left(r\right)\\ =g\text{'}\text{'}\left(r\right)+\frac{n-1}{r}g\text{'}\left(r\right)\\ =\frac{{d}^{2}g}{d{r}^{2}}+\frac{n-1}{r}·\frac{\mathrm{dg}}{dr}\end{array}$

コード(Emacs)

Python 3

#!/usr/bin/env python3
from sympy import pprint, symbols, sqrt, Derivative, Function

n = 5
xs = symbols([f'x{i}' for i in range(1, n + 1)])
r = sqrt(sum([x ** 2 for x in xs]))
f = r ** 2
s = sum([Derivative(f, x, 2) for x in xs])

for t in [f, s, s.doit()]:
pprint(t)
print()


$./sample8.py 2 2 2 2 2 x₁ + x₂ + x₃ + x₄ + x₅ 2 2 2 ∂ ⎛ 2 2 2 2 2⎞ ∂ ⎛ 2 2 2 2 2⎞ ∂ ⎛ ────⎝x₁ + x₂ + x₃ + x₄ + x₅ ⎠ + ────⎝x₁ + x₂ + x₃ + x₄ + x₅ ⎠ + ────⎝x 2 2 2 ∂x₁ ∂x₂ ∂x₃ 2 2 2 2 2 2 2⎞ ∂ ⎛ 2 2 2 2 2⎞ ∂ ⎛ 2 ₁ + x₂ + x₃ + x₄ + x₅ ⎠ + ────⎝x₁ + x₂ + x₃ + x₄ + x₅ ⎠ + ────⎝x₁ + x 2 2 ∂x₄ ∂x₅ 2 2 2 2⎞ ₂ + x₃ + x₄ + x₅ ⎠ 10$