Workspace IndexMath › Day 29

Gradient Descent and Convex Intuition TODO

Math · Day 29 / 52 · October — Calculus & Optimization (Day 27-34)

Concept

Gradient descent is an optimization method that exploits the fact that the gradient of the objective function points in the direction of steepest ascent, and repeatedly moves a step of size equal to the learning rate in the opposite direction. A function is convex if the line segment joining any two points in its domain always lies on or above the function's graph; this property guarantees that a local minimum is also the global minimum, and that a point where the gradient is zero is optimal. For a smooth convex function whose gradient is L-Lipschitz continuous, choosing a learning rate at or below 1/L guarantees convergence, and adding strong convexity yields a faster, exponentially decaying error rate. A learning rate that's too large causes divergence, one that's too small is slow, and poor conditioning causes zig-zagging in narrow, elongated valleys — which is why techniques like momentum, adaptive learning rates, and preconditioning are used to mitigate it.

In numerical optimization beyond machine learning — market-making parameter tuning, calibration — you need to tell whether a failure to converge comes from the problem's non-convexity or from a learning-rate/conditioning issue.

Code & Formula

# Day 29 — Gradient Descent / Convex 직관
# 볼록함수 f(x) = (x - 3)^2 위에서 경사하강법을 돌려 최소점 x=3 으로 수렴하는 과정을 본다.

def f(x):
    return (x - 3) ** 2


def f_prime(x):
    return 2 * (x - 3)


x = 10.0  # 시작점
learning_rate = 0.1
history = [x]

for step in range(30):
    grad = f_prime(x)
    x = x - learning_rate * grad
    history.append(x)

print("경사하강 진행 (x, f(x)):")
for i in [0, 1, 2, 5, 10, 20, len(history) - 1]:
    xi = history[i]
    print(f"  step {i:2d}: x = {xi:.6f}, f(x) = {f(xi):.8f}")

print(f"\n최종 x = {history[-1]:.6f} (참값 x* = 3)")
print(f"최종 f(x) = {f(history[-1]):.10f} (참값 f(x*) = 0)")

Exercise

Construct a 2D quadratic function with a deliberately poor condition number, run both plain and momentum-based gradient descent on it across several learning rates, and compare the iteration counts and trajectories visually.

Practical Connection

The LMSR cost function is convex, so properties like well-defined prices and a bounded loss follow directly from convexity, and this same optimization toolkit is exactly what you use when calibrating parameters against real data.

Where it lands in Jayverse

Key expressions

Words and phrases from this page worth keeping, with the Korean meaning and the sentence they come from.

Expression뜻 · 쓰이는 자리
exploit the fact that~라는 사실을 이용하다 · 경사가 가장 가파른 방향을 가리킨다는 성질을 활용함 · "exploits the fact that the gradient... points in the direction"
steepest ascent가장 가파르게 오르는 방향(최대 상승 방향) · 경사의 방향을 설명하는 표현 · "the direction of steepest ascent"
guarantee convergence수렴을 보장하다 · 학습률을 특정 값 이하로 두면 수렴이 보장됨 · "choosing a learning rate at or below 1/L guarantees convergence"
zig-zagging지그재그로 왔다갔다 하는 것 · 좁고 긴 골짜기에서 최적화가 갈지자로 움직이는 현상 · "poor conditioning causes zig-zagging in narrow, elongated valleys"
poor conditioning조건수가 나쁜 상태 · 골짜기가 좁고 길어 최적화가 어려운 상황을 가리킴 · "poor conditioning causes zig-zagging"
mitigate완화하다, 줄이다 · 모멘텀·적응적 학습률 등으로 지그재그를 완화함 · "techniques like momentum... are used to mitigate it"
follow directly from~로부터 바로(당연히) 도출되다 · 볼록성만으로 여러 좋은 성질이 자동으로 성립함 · "properties like well-defined prices... follow directly from convexity"
L-Lipschitz립시츠 연속(L-Lipschitz continuous) · 기울기 변화 속도가 상수 L로 제한됨을 뜻하는 수학적 성질, 수렴 보장의 전제조건. "whose gradient is L-Lipschitz continuous"
LMSR로그 마켓 스코어링 룰(Logarithmic Market Scoring Rule, LMSR) · 예측시장에서 쓰이는 볼록 비용함수 기반 가격 결정 메커니즘. "The LMSR cost function is convex"
condition number조건수(condition number) · 골짜기가 얼마나 좁고 길쭉한지를 나타내는, 최적화 난이도의 척도. "a deliberately poor condition number, run both plain and momentum-based gradient descent"

If you study this on a given day, add a note link and a ✅ to this line in the source curriculum (docs/knowledge/math-50-curriculum.md) and this spot will lead straight to the note body. You can also write directly on this page — but regenerating overwrites it, so it's safer to keep anything you want to save as markdown under docs/algorithms/.


한국어

Gradient Descent / Convex 직관 TODO

Math · Day 29 / 52 · 10월 — 미적분·최적화 (Day 27–34)

개념

경사하강법은 목적함수의 기울기가 가장 가파른 상승 방향임을 이용해, 그 반대 방향으로 학습률만큼 이동하기를 반복하는 최적화 방법이다. 볼록함수는 정의역의 두 점을 잇는 선분이 항상 함수 그래프 위에 있는 함수이며, 이 성질 덕분에 국소 최소점이 곧 전역 최소점이고 기울기가 0인 점이 최적해가 된다. 기울기가 L-립시츠 연속인 매끄러운 볼록함수에서는 학습률을 1/L 이하로 잡으면 수렴이 보장되고, 강볼록성까지 있으면 오차가 기하급수적으로 줄어드는 더 빠른 속도를 얻는다. 학습률이 너무 크면 발산하고 너무 작으면 느리며, 조건수가 나쁘면 좁고 긴 골짜기에서 지그재그로 진동한다. 이를 완화하려고 모멘텀, 적응적 학습률, 전처리 같은 기법을 쓴다.

머신러닝뿐 아니라 시장조성 파라미터 튜닝이나 캘리브레이션 같은 수치 최적화에서, 수렴하지 않는 원인이 문제의 비볼록성인지 학습률·조건수 문제인지 구분해야 한다.

코드 · 수식

# Day 29 — Gradient Descent / Convex 직관
# 볼록함수 f(x) = (x - 3)^2 위에서 경사하강법을 돌려 최소점 x=3 으로 수렴하는 과정을 본다.

def f(x):
    return (x - 3) ** 2


def f_prime(x):
    return 2 * (x - 3)


x = 10.0  # 시작점
learning_rate = 0.1
history = [x]

for step in range(30):
    grad = f_prime(x)
    x = x - learning_rate * grad
    history.append(x)

print("경사하강 진행 (x, f(x)):")
for i in [0, 1, 2, 5, 10, 20, len(history) - 1]:
    xi = history[i]
    print(f"  step {i:2d}: x = {xi:.6f}, f(x) = {f(xi):.8f}")

print(f"\n최종 x = {history[-1]:.6f} (참값 x* = 3)")
print(f"최종 f(x) = {f(history[-1]):.10f} (참값 f(x*) = 0)")

연습

2차원 이차함수의 조건수를 크게 만들어 놓고 경사하강법을 순수 버전과 모멘텀 버전으로 돌려, 학습률을 바꿔가며 반복 횟수와 궤적을 그림으로 비교하라.

실무 · Verex 연결

LMSR의 비용함수는 볼록이라 가격과 손실 상한 같은 성질이 볼록성에서 곧바로 따라오고, 파라미터를 데이터에 맞춰 캘리브레이션할 때 이 최적화 도구가 그대로 쓰인다.

Jayverse에서의 위치

핵심 표현

이 페이지의 영어 본문에서 배울 만한 단어와 표현, 뜻과 나온 자리.

Expression뜻 · 쓰이는 자리
exploit the fact that~라는 사실을 이용하다 · 경사가 가장 가파른 방향을 가리킨다는 성질을 활용함 · "exploits the fact that the gradient... points in the direction"
steepest ascent가장 가파르게 오르는 방향(최대 상승 방향) · 경사의 방향을 설명하는 표현 · "the direction of steepest ascent"
guarantee convergence수렴을 보장하다 · 학습률을 특정 값 이하로 두면 수렴이 보장됨 · "choosing a learning rate at or below 1/L guarantees convergence"
zig-zagging지그재그로 왔다갔다 하는 것 · 좁고 긴 골짜기에서 최적화가 갈지자로 움직이는 현상 · "poor conditioning causes zig-zagging in narrow, elongated valleys"
poor conditioning조건수가 나쁜 상태 · 골짜기가 좁고 길어 최적화가 어려운 상황을 가리킴 · "poor conditioning causes zig-zagging"
mitigate완화하다, 줄이다 · 모멘텀·적응적 학습률 등으로 지그재그를 완화함 · "techniques like momentum... are used to mitigate it"
follow directly from~로부터 바로(당연히) 도출되다 · 볼록성만으로 여러 좋은 성질이 자동으로 성립함 · "properties like well-defined prices... follow directly from convexity"
L-Lipschitz립시츠 연속(L-Lipschitz continuous) · 기울기 변화 속도가 상수 L로 제한됨을 뜻하는 수학적 성질, 수렴 보장의 전제조건. "whose gradient is L-Lipschitz continuous"
LMSR로그 마켓 스코어링 룰(Logarithmic Market Scoring Rule, LMSR) · 예측시장에서 쓰이는 볼록 비용함수 기반 가격 결정 메커니즘. "The LMSR cost function is convex"
condition number조건수(condition number) · 골짜기가 얼마나 좁고 길쭉한지를 나타내는, 최적화 난이도의 척도. "a deliberately poor condition number, run both plain and momentum-based gradient descent"

공부한 날 원본 커리큘럼(docs/knowledge/math-50-curriculum.md)의 이 줄에 노트 링크와 ✅ 를 붙이면, 이 자리는 노트 본문으로 바로 이어집니다. 노트 없이 이 페이지에 바로 적어도 됩니다 — 다만 다시 생성하면 덮어쓰이므로, 남길 글은 docs/algorithms/ 의 마크다운으로 쓰는 편이 안전합니다.

← 1032. 편미분/그래디언트1034. 라그랑주/KKT(개념) →