7.16 방향 도함수와 최대 증가 방향

1. 방향 도함수의 정의

다변수 스칼라 함수 f: \mathbb{R}^n \to \mathbb{R}가 점 \mathbf{x}_0에서 미분 가능하다고 하자. 단위 벡터 \hat{\mathbf{u}} \in \mathbb{R}^n (\lVert \hat{\mathbf{u}} \rVert = 1) 방향으로의 방향 도함수(directional derivative)는 다음과 같이 정의된다.

D_{\hat{\mathbf{u}}} f(\mathbf{x}_0) = \lim_{h \to 0} \frac{f(\mathbf{x}_0 + h \hat{\mathbf{u}}) - f(\mathbf{x}_0)}{h}

이 정의는 점 \mathbf{x}_0에서 \hat{\mathbf{u}} 방향으로 이동할 때 함수값의 순간 변화율을 나타낸다. 편미분은 방향 도함수의 특수한 경우로서, 좌표축 방향의 단위 벡터 \mathbf{e}_i에 대한 방향 도함수가 바로 i번째 편미분이다.

D_{\mathbf{e}_i} f = \frac{\partial f}{\partial x_i}

2. 그래디언트를 이용한 계산

f가 점 \mathbf{x}_0에서 미분 가능하면, 방향 도함수는 그래디언트와 방향 벡터의 내적으로 간단히 계산된다.

D_{\hat{\mathbf{u}}} f(\mathbf{x}_0) = \nabla f(\mathbf{x}_0) \cdot \hat{\mathbf{u}} = \sum_{i=1}^{n} \frac{\partial f}{\partial x_i}(\mathbf{x}_0) \, u_i

여기서 \hat{\mathbf{u}} = [u_1, u_2, \dots, u_n]^T이다.

2.1 증명

f\mathbf{x}_0에서 미분 가능하면, 전미분(total differential)에 의해

f(\mathbf{x}_0 + h\hat{\mathbf{u}}) = f(\mathbf{x}_0) + \nabla f(\mathbf{x}_0) \cdot (h\hat{\mathbf{u}}) + o(h)

가 성립한다. 양변에서 f(\mathbf{x}_0)를 빼고 h로 나누면

\frac{f(\mathbf{x}_0 + h\hat{\mathbf{u}}) - f(\mathbf{x}_0)}{h} = \nabla f(\mathbf{x}_0) \cdot \hat{\mathbf{u}} + \frac{o(h)}{h}

이며, h \to 0으로 극한을 취하면

D_{\hat{\mathbf{u}}} f(\mathbf{x}_0) = \nabla f(\mathbf{x}_0) \cdot \hat{\mathbf{u}}

를 얻는다.

3. 변수 함수에서의 방향 도함수

f(x, y)에 대하여 점 (x_0, y_0)에서 단위 벡터 \hat{\mathbf{u}} = (\cos\theta, \sin\theta) 방향으로의 방향 도함수는

D_{\hat{\mathbf{u}}} f = \frac{\partial f}{\partial x} \cos\theta + \frac{\partial f}{\partial y} \sin\theta

이다. 여기서 \thetax축 양의 방향으로부터 측정한 \hat{\mathbf{u}}의 방향각이다.

3.1 계산 예제

f(x, y) = x^2 y + 3xy^2에서 점 (1, 2)에서 \hat{\mathbf{u}} = \left(\frac{3}{5}, \frac{4}{5}\right) 방향으로의 방향 도함수를 구하자.

편미분을 계산하면

\frac{\partial f}{\partial x} = 2xy + 3y^2, \quad \frac{\partial f}{\partial y} = x^2 + 6xy

(1, 2)에서

\frac{\partial f}{\partial x}(1, 2) = 2(1)(2) + 3(4) = 16

\frac{\partial f}{\partial y}(1, 2) = 1 + 6(1)(2) = 13

따라서

D_{\hat{\mathbf{u}}} f(1, 2) = 16 \cdot \frac{3}{5} + 13 \cdot \frac{4}{5} = \frac{48 + 52}{5} = 20

이다.

4. 최대 증가 방향의 유도

방향 도함수를 단위 벡터 \hat{\mathbf{u}}의 함수로 보면

D_{\hat{\mathbf{u}}} f = \nabla f \cdot \hat{\mathbf{u}} = \lVert \nabla f \rVert \lVert \hat{\mathbf{u}} \rVert \cos\phi = \lVert \nabla f \rVert \cos\phi

이다. 여기서 \phi는 그래디언트 \nabla f와 방향 벡터 \hat{\mathbf{u}} 사이의 각도이다.

\cos\phi의 범위가 [-1, 1]이므로 다음 결과를 얻는다.

4.1 정리: 최대 증가 방향

\nabla f(\mathbf{x}_0) \neq \mathbf{0}일 때, 방향 도함수 D_{\hat{\mathbf{u}}} f(\mathbf{x}_0)는:

  1. \hat{\mathbf{u}} = \dfrac{\nabla f}{\lVert \nabla f \rVert}일 때 최댓값 \lVert \nabla f \rVert을 가진다 (\phi = 0)
  2. \hat{\mathbf{u}} = -\dfrac{\nabla f}{\lVert \nabla f \rVert}일 때 최솟값 -\lVert \nabla f \rVert을 가진다 (\phi = \pi)
  3. \hat{\mathbf{u}} \perp \nabla f일 때 값이 0이다 (\phi = \pi/2)

따라서 그래디언트 방향이 함수의 최대 증가 방향이고, 음의 그래디언트 방향이 최대 감소 방향이다.

5. 라그랑주 승수법에 의한 엄밀한 증명

최대 증가 방향을 구하는 문제를 제약 최적화(constrained optimization) 문제로 형식화할 수도 있다.

\max_{\hat{\mathbf{u}}} \nabla f \cdot \hat{\mathbf{u}} \quad \text{subject to} \quad \lVert \hat{\mathbf{u}} \rVert^2 = 1

라그랑주 승수 \lambda를 도입하여 라그랑주 함수를 구성하면

\mathcal{L}(\hat{\mathbf{u}}, \lambda) = \nabla f \cdot \hat{\mathbf{u}} - \lambda (\hat{\mathbf{u}}^T \hat{\mathbf{u}} - 1)

정상 조건(stationarity condition)은

\frac{\partial \mathcal{L}}{\partial \hat{\mathbf{u}}} = \nabla f - 2\lambda \hat{\mathbf{u}} = \mathbf{0}

이므로

\hat{\mathbf{u}} = \frac{\nabla f}{2\lambda}

이다. 제약 조건 \lVert \hat{\mathbf{u}} \rVert = 1을 적용하면 \lambda = \frac{\lVert \nabla f \rVert}{2}이고, 따라서

\hat{\mathbf{u}}^* = \frac{\nabla f}{\lVert \nabla f \rVert}

이 최적 방향임을 확인할 수 있다.

6. 고차원 공간에서의 방향 도함수

n차원 공간에서 단위 벡터 \hat{\mathbf{u}}를 구면 좌표(spherical coordinates)로 매개변수화하면, 방향 도함수는 n-1개의 각도 변수에 대한 함수가 된다. 그래디언트 벡터 \nabla f = [g_1, g_2, \dots, g_n]^T에 대해

D_{\hat{\mathbf{u}}} f = \sum_{i=1}^{n} g_i u_i

이며, 최대 증가 방향의 각 성분은

u_i^* = \frac{g_i}{\sqrt{g_1^2 + g_2^2 + \cdots + g_n^2}}

이다.

7. 경사법과 로봇공학 응용

7.1 경사 하강법

음의 그래디언트 방향이 최대 감소 방향이라는 성질은 경사 하강법(gradient descent)의 이론적 기초가 된다. 비용 함수 J(\mathbf{q})를 최소화하기 위해

\mathbf{q}_{k+1} = \mathbf{q}_k - \alpha_k \nabla J(\mathbf{q}_k)

로 반복 갱신한다. 학습률(step size) \alpha_k의 선택이 수렴 속도에 큰 영향을 미치며, 대표적인 전략은 다음과 같다.

학습률 전략조건특성
고정 학습률\alpha_k = \alpha (상수)단순하지만 수렴 보장 조건이 제한적
아르미호 조건J(\mathbf{q}_k - \alpha \nabla J) \leq J(\mathbf{q}_k) - c \alpha \lVert \nabla J \rVert^2충분한 감소를 보장
정확 직선 탐색\alpha_k = \arg\min_\alpha J(\mathbf{q}_k - \alpha \nabla J)매 단계 최적이지만 계산 비용이 큼

7.2 역기구학에서의 경사법 적용

말단장치의 원하는 위치 \mathbf{x}_d와 현재 위치 \mathbf{f}(\mathbf{q}) 사이의 오차 함수

e(\mathbf{q}) = \frac{1}{2} \lVert \mathbf{x}_d - \mathbf{f}(\mathbf{q}) \rVert^2

의 그래디언트는

\nabla e(\mathbf{q}) = -\mathbf{J}^T(\mathbf{q}) \bigl(\mathbf{x}_d - \mathbf{f}(\mathbf{q})\bigr)

이다. 경사 하강법을 적용하면

\mathbf{q}_{k+1} = \mathbf{q}_k + \alpha \mathbf{J}^T(\mathbf{q}_k) \bigl(\mathbf{x}_d - \mathbf{f}(\mathbf{q}_k)\bigr)

이 되며, 이를 전치 야코비 방법(transpose Jacobian method)이라 한다. 이 방법은 야코비 행렬의 역행렬이나 의사역행렬을 계산할 필요가 없으므로 계산 효율이 높다.

7.3 포텐셜 필드에서의 최대 반발 방향

장애물 회피에서 로봇 위치 \mathbf{x}에서의 반발 포텐셜 U_{\text{rep}}(\mathbf{x})의 음의 그래디언트 방향은 장애물로부터 가장 빠르게 벗어나는 방향이다. 인력 포텐셜 U_{\text{att}}(\mathbf{x})의 음의 그래디언트 방향은 목표점을 향하는 최단 경로 방향이다. 두 그래디언트를 합성하면

\mathbf{F}(\mathbf{x}) = -\nabla U_{\text{att}}(\mathbf{x}) - \nabla U_{\text{rep}}(\mathbf{x})

이 되며, 로봇은 이 합력 방향으로 이동한다.

8. 차 방향 도함수

방향 \hat{\mathbf{u}}로의 2차 방향 도함수(second directional derivative)는

D_{\hat{\mathbf{u}}}^2 f = D_{\hat{\mathbf{u}}} (D_{\hat{\mathbf{u}}} f) = \hat{\mathbf{u}}^T \mathbf{H} \hat{\mathbf{u}}

로 주어진다. 여기서 \mathbf{H}는 헤세 행렬(Hessian matrix)이다. 이 값은 \hat{\mathbf{u}} 방향으로의 함수의 곡률(curvature)을 나타내며, 다음과 같이 해석된다.

  • D_{\hat{\mathbf{u}}}^2 f > 0: 해당 방향으로 함수가 위로 볼록(아래로 오목)
  • D_{\hat{\mathbf{u}}}^2 f < 0: 해당 방향으로 함수가 아래로 볼록(위로 오목)
  • D_{\hat{\mathbf{u}}}^2 f = 0: 해당 방향으로 변곡점

2차 방향 도함수는 뉴턴법(Newton’s method) 등 2차 최적화 알고리즘에서 수렴 속도를 향상시키는 데 활용된다.

9. 혼합 방향 도함수

서로 다른 두 방향 \hat{\mathbf{u}}\hat{\mathbf{v}}에 대한 혼합 방향 도함수(mixed directional derivative)는

D_{\hat{\mathbf{v}}} (D_{\hat{\mathbf{u}}} f) = \hat{\mathbf{v}}^T \mathbf{H} \hat{\mathbf{u}}

이다. fC^2 함수이면 헤세 행렬이 대칭이므로

D_{\hat{\mathbf{v}}} (D_{\hat{\mathbf{u}}} f) = D_{\hat{\mathbf{u}}} (D_{\hat{\mathbf{v}}} f)

가 성립한다. 이는 미분 순서의 교환 가능성을 방향 도함수의 관점에서 재해석한 것이다.

10. 요약

방향 도함수는 임의의 방향으로의 함수 변화율을 정량화하는 도구이며, 그래디언트 벡터와의 내적으로 효율적으로 계산된다. 그래디언트 방향이 함수의 최대 증가 방향이라는 기본 정리는 경사 하강법, 역기구학의 전치 야코비 방법, 포텐셜 필드 경로 계획 등 로봇공학의 핵심 알고리즘에 이론적 토대를 제공한다.


11. 참고 문헌

  • Marsden, J. E., & Tromba, A. J. (2012). Vector Calculus. 6th ed. W. H. Freeman.
  • Nocedal, J., & Wright, S. J. (2006). Numerical Optimization. 2nd ed. Springer.
  • Siciliano, B., Sciavicco, L., Villani, L., & Oriolo, G. (2009). Robotics: Modelling, Planning and Control. Springer.
  • Wolovich, W. A., & Elliott, H. (1984). “A Computational Technique for Inverse Kinematics.” Proceedings of the 23rd IEEE Conference on Decision and Control, 1359–1363.
  • Boyd, S., & Vandenberghe, L. (2004). Convex Optimization. Cambridge University Press.

v 0.1