勾配(grad)の定義と幾何学的意味

スカラー場が空間的にどのように変化するかを知りたいとき、その変化の方向と大きさを教えてくれるのが勾配(gradient)です。勾配はスカラー場からベクトル場を生成する演算であり、ベクトル解析の最も基本的な概念の一つです。

電場は電位の勾配、力は位置エネルギーの勾配、熱流は温度の勾配に関連しています。勾配を理解することは、物理現象の空間的な変化を定量的に捉える第一歩です。

本記事の内容

  • 勾配の定義
  • 幾何学的意味(最大増加方向、等位面に垂直)
  • 方向微分との関係
  • 具体例
  • Pythonでの可視化

前提知識

勾配の定義

スカラー場 $\phi(x, y, z)$ の勾配は次で定義されます。

$$ \boxed{\nabla \phi = \text{grad} \, \phi = \frac{\partial \phi}{\partial x}\bm{e}_x + \frac{\partial \phi}{\partial y}\bm{e}_y + \frac{\partial \phi}{\partial z}\bm{e}_z = \left(\frac{\partial \phi}{\partial x}, \frac{\partial \phi}{\partial y}, \frac{\partial \phi}{\partial z}\right)} $$

ここで $\nabla$(ナブラ)は微分演算子ベクトルです。

$$ \nabla = \left(\frac{\partial}{\partial x}, \frac{\partial}{\partial y}, \frac{\partial}{\partial z}\right) $$

幾何学的意味

1. 最大増加方向

勾配 $\nabla \phi$ は、スカラー場 $\phi$ が最も急に増加する方向を向きます。その大きさ $|\nabla \phi|$ は最大増加率に等しくなります。

2. 等位面に垂直

勾配ベクトルは等位面 $\phi = c$ に垂直です。

証明: 等位面上の任意の曲線 $\bm{r}(t)$ に対し $\phi(\bm{r}(t)) = c$。両辺を $t$ で微分すると、

$$ \frac{d\phi}{dt} = \nabla\phi \cdot \frac{d\bm{r}}{dt} = 0 $$

$d\bm{r}/dt$ は等位面の接線ベクトルなので、$\nabla\phi$ は等位面に垂直です。

方向微分

単位ベクトル $\hat{\bm{n}}$ の方向への $\phi$ の変化率を方向微分と呼びます。

$$ \frac{\partial \phi}{\partial n} = \nabla\phi \cdot \hat{\bm{n}} = |\nabla\phi|\cos\theta $$

ここで $\theta$ は $\nabla\phi$ と $\hat{\bm{n}}$ のなす角です。

  • $\theta = 0$($\nabla\phi$ と同方向): 変化率最大 $= |\nabla\phi|$
  • $\theta = \pi/2$(等位面に沿う): 変化率 $= 0$
  • $\theta = \pi$($\nabla\phi$ と逆方向): 変化率最小 $= -|\nabla\phi|$

勾配の性質

  1. 線形性: $\nabla(a\phi + b\psi) = a\nabla\phi + b\nabla\psi$
  2. 積の法則: $\nabla(\phi\psi) = \phi\nabla\psi + \psi\nabla\phi$
  3. 連鎖律: $\nabla f(\phi) = f'(\phi)\nabla\phi$

具体例

例1: $\phi = x^2 + y^2 + z^2$(球対称スカラー場)

$$ \nabla\phi = (2x, 2y, 2z) = 2\bm{r} $$

勾配は原点から放射状に外向き。等位面は同心球面です。

例2: $\phi = xy + z$

$$ \nabla\phi = (y, x, 1) $$

例3: 点 $(1, 2, 3)$ での勾配と方向微分

$\phi = x^2y + yz^2$ の点 $(1, 2, 3)$ での勾配:

$$ \nabla\phi = (2xy, x^2+z^2, 2yz) = (4, 10, 12) $$

方向 $\hat{\bm{n}} = (1, 1, 1)/\sqrt{3}$ への方向微分:

$$ \frac{\partial\phi}{\partial n} = (4, 10, 12) \cdot \frac{(1, 1, 1)}{\sqrt{3}} = \frac{26}{\sqrt{3}} \approx 15.0 $$

Pythonでの実装

import numpy as np
import matplotlib.pyplot as plt

x = np.linspace(-3, 3, 200)
y = np.linspace(-3, 3, 200)
X, Y = np.meshgrid(x, y)

# スカラー場: phi = sin(x) * cos(y)
phi = np.sin(X) * np.cos(Y)

# 勾配の計算(解析的)
grad_x = np.cos(X) * np.cos(Y)
grad_y = -np.sin(X) * np.sin(Y)

# 粗いグリッドでquiver
x_q = np.linspace(-3, 3, 15)
y_q = np.linspace(-3, 3, 15)
Xq, Yq = np.meshgrid(x_q, y_q)
Gx = np.cos(Xq) * np.cos(Yq)
Gy = -np.sin(Xq) * np.sin(Yq)

fig, axes = plt.subplots(1, 2, figsize=(14, 6))

# 等高線 + 勾配ベクトル
cs = axes[0].contourf(X, Y, phi, levels=20, cmap='RdBu_r', alpha=0.8)
axes[0].contour(X, Y, phi, levels=10, colors='k', linewidths=0.5)
axes[0].quiver(Xq, Yq, Gx, Gy, color='black', alpha=0.7, scale=15)
plt.colorbar(cs, ax=axes[0])
axes[0].set_title('$\\phi = \\sin x \\cos y$ と勾配ベクトル $\\nabla\\phi$')
axes[0].set_xlabel('x')
axes[0].set_ylabel('y')
axes[0].set_aspect('equal')

# ガウス型ポテンシャル + 勾配
phi2 = np.exp(-(X**2 + Y**2))
Gx2_q = -2*Xq * np.exp(-(Xq**2 + Yq**2))
Gy2_q = -2*Yq * np.exp(-(Xq**2 + Yq**2))

cs2 = axes[1].contourf(X, Y, phi2, levels=20, cmap='viridis', alpha=0.8)
axes[1].contour(X, Y, phi2, levels=10, colors='white', linewidths=0.5)
axes[1].quiver(Xq, Yq, Gx2_q, Gy2_q, color='red', alpha=0.8, scale=5)
plt.colorbar(cs2, ax=axes[1])
axes[1].set_title('$\\phi = e^{-(x^2+y^2)}$ と勾配(等位線に垂直)')
axes[1].set_xlabel('x')
axes[1].set_ylabel('y')
axes[1].set_aspect('equal')

plt.tight_layout()
plt.savefig('gradient_vector.png', dpi=150, bbox_inches='tight')
plt.show()

勾配ベクトルが等高線に垂直に配置されていること、スカラー場の値が増加する方向を向いていることが明確に確認できます。

まとめ

  • 勾配 $\nabla\phi = (\partial\phi/\partial x, \partial\phi/\partial y, \partial\phi/\partial z)$
  • 勾配は最大増加方向を向き、その大きさは最大変化率
  • 勾配は等位面に垂直
  • 方向微分 $\partial\phi/\partial n = \nabla\phi \cdot \hat{\bm{n}}$
  • 物理応用: 電場 $\bm{E} = -\nabla V$、力 $\bm{F} = -\nabla U$

次のステップとして、以下の記事も参考にしてください。