Workspace IndexMath › Day 33

Taylor Series (First-Order Approximation) TODO

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

Concept

The Taylor series approximates a sufficiently smooth function near a point a using a polynomial built from the function's derivatives at that point. The first-order approximation is f(x) ≈ f(a) + f'(a)(x−a) — replacing the curve with its tangent line — and since the error is dominated by the quadratic term, it shrinks proportionally to (x−a)² as x approaches a. In the multivariable case this becomes f(x) ≈ f(a) + ∇f(a)ᵀ(x−a), so the gradient vector becomes the local linear model — the foundation that optimization and numerical methods like gradient descent and Newton's method stand on. Common approximations such as (1+x)^n ≈ 1 + nx, e^x ≈ 1 + x, and ln(1+x) ≈ x are all first-order Taylor expansions around a=0, and all come with the same caveat: they only hold for small |x|. Whenever you use an approximation, you must always state which point it's centered near and how much error is tolerable — otherwise a linearization taken far from that point silently gives you a wrong answer.

Linearization is the default tool for quickly estimating a price curve's local sensitivity (slippage, delta) or the impact of a fee change, and knowing the valid range is what makes that estimate safe to rely on.

Code & Formula

# Day 33 — 테일러 급수(1차 근사)
# f(x) ≈ f(a) + f'(a)(x-a) 로 exp(x)를 a=0에서 선형근사하고, x가 a에서 멀어질수록 오차가 커짐을 본다.

import math


def f(x):
    return math.exp(x)


def f_prime(x):
    return math.exp(x)  # exp의 도함수는 자기 자신


def taylor_1st_order(x, a):
    return f(a) + f_prime(a) * (x - a)


a = 0.0
print(f"e^x 를 a={a} 에서 1차 테일러 근사:\n")
print(f"{'x':>6} {'실제값':>12} {'근사값':>12} {'오차':>12}")
for x in [0.01, 0.1, 0.3, 0.5, 1.0, 2.0]:
    exact = f(x)
    approx = taylor_1st_order(x, a)
    err = abs(exact - approx)
    print(f"{x:6.2f} {exact:12.6f} {approx:12.6f} {err:12.6f}")

print("\n오차는 대략 (x-a)^2 에 비례해서 커진다 (2차 항이 지배).")
for x in [0.1, 0.2, 0.4]:
    err = abs(f(x) - taylor_1st_order(x, a))
    print(f"  x={x}: 오차={err:.6f}, (x-a)^2={x**2:.6f}, 비율={err / x**2:.4f}")

Exercise

Compute ln(1+x) using both its first-order approximation at x=0 and its true value at x=0.01, 0.1, and 0.5, and tabulate how the relative error grows.

Practical Connection

Expanding LMSR's price function to first order around the current inventory gives a closed-form, fast estimate of expected fill price and slippage for a small order — and that same expansion explains why the estimate breaks down as order size grows.

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뜻 · 쓰이는 자리
shrink proportionally to~에 비례해서 줄어들다 · 오차가 어떻게 작아지는지 설명할 때. "the error... shrinks proportionally to (x−a)²"
silently (give a wrong answer)티 안 나게, 모르는 새 · 경고 없이 오답이 나올 때. "silently gives you a wrong answer"
closed-form닫힌 형태의(수식으로 바로 풀리는) · 근사식이 빠르게 계산됨을 말할 때. "a closed-form, fast estimate"
come with the same caveat같은 단서(주의사항)가 따라붙다 · 여러 근사식이 공통 한계를 가질 때. "all come with the same caveat"
centered near~을 중심으로 한 · 근사가 기준점 근처에서만 유효할 때. "which point it's centered near"
stand on~위에 기반을 두다 · 다른 방법론의 토대가 될 때. "the foundation that optimization... stand on"
tolerable감내할 수 있는, 허용 가능한 · 오차의 허용 범위를 말할 때. "how much error is tolerable"
LMSR로그마켓스코어링룰(Logarithmic Market Scoring Rule) · 예측시장 AMM의 가격함수, 1차 테일러 전개로 슬리피지를 근사할 때 대상이 됨. "Expanding LMSR's price function to first order"

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/.


한국어

테일러 급수(1차 근사) TODO

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

개념

테일러 급수는 충분히 매끄러운 함수를 한 점 a 근방에서 그 점에서의 도함수 값들로 만든 다항식으로 근사하는 도구다. 1차 근사는 f(x) ≈ f(a) + f'(a)(x-a)로, 곡선을 접선으로 바꾸는 것이며 오차는 2차 항이 지배하므로 x가 a에 가까울수록 (x-a)²에 비례해 줄어든다. 다변수에서는 f(x) ≈ f(a) + ∇f(a)ᵀ(x-a)가 되어 기울기 벡터가 국소 선형 모델이 되고, 이것이 경사하강법과 뉴턴법 같은 최적화·수치해석 기법이 서 있는 토대다. 자주 쓰는 근사인 (1+x)^n ≈ 1 + nx, e^x ≈ 1 + x, ln(1+x) ≈ x도 모두 a=0에서의 1차 테일러 전개이며, |x|가 작을 때만 유효하다는 조건이 함께 따라온다. 근사를 쓸 때는 항상 '어느 점 근방인가'와 '오차가 어느 정도까지 허용되는가'를 명시해야 하며, 그렇지 않으면 멀리서 쓴 선형화가 조용히 틀린 답을 준다.

가격 곡선의 국소 민감도(슬리피지, 델타)나 수수료 변화의 영향을 빠르게 추정할 때 선형화가 기본 도구이고, 어디까지가 유효 범위인지 아는 것이 그 추정을 안전하게 만든다.

코드 · 수식

# Day 33 — 테일러 급수(1차 근사)
# f(x) ≈ f(a) + f'(a)(x-a) 로 exp(x)를 a=0에서 선형근사하고, x가 a에서 멀어질수록 오차가 커짐을 본다.

import math


def f(x):
    return math.exp(x)


def f_prime(x):
    return math.exp(x)  # exp의 도함수는 자기 자신


def taylor_1st_order(x, a):
    return f(a) + f_prime(a) * (x - a)


a = 0.0
print(f"e^x 를 a={a} 에서 1차 테일러 근사:\n")
print(f"{'x':>6} {'실제값':>12} {'근사값':>12} {'오차':>12}")
for x in [0.01, 0.1, 0.3, 0.5, 1.0, 2.0]:
    exact = f(x)
    approx = taylor_1st_order(x, a)
    err = abs(exact - approx)
    print(f"{x:6.2f} {exact:12.6f} {approx:12.6f} {err:12.6f}")

print("\n오차는 대략 (x-a)^2 에 비례해서 커진다 (2차 항이 지배).")
for x in [0.1, 0.2, 0.4]:
    err = abs(f(x) - taylor_1st_order(x, a))
    print(f"  x={x}: 오차={err:.6f}, (x-a)^2={x**2:.6f}, 비율={err / x**2:.4f}")

연습

ln(1+x)를 x=0 근방 1차 근사와 실제 값으로 x=0.01, 0.1, 0.5에서 각각 계산해 상대 오차가 어떻게 커지는지 표로 적어 보라.

실무 · Verex 연결

LMSR의 가격 함수를 현재 재고 근방에서 1차 전개하면 소량 주문의 예상 체결가와 슬리피지를 닫힌 형태로 빠르게 추정할 수 있고, 주문이 커질수록 그 추정이 왜 빗나가는지도 같은 식에서 설명된다.

Jayverse에서의 위치

핵심 표현

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

Expression뜻 · 쓰이는 자리
shrink proportionally to~에 비례해서 줄어들다 · 오차가 어떻게 작아지는지 설명할 때. "the error... shrinks proportionally to (x−a)²"
silently (give a wrong answer)티 안 나게, 모르는 새 · 경고 없이 오답이 나올 때. "silently gives you a wrong answer"
closed-form닫힌 형태의(수식으로 바로 풀리는) · 근사식이 빠르게 계산됨을 말할 때. "a closed-form, fast estimate"
come with the same caveat같은 단서(주의사항)가 따라붙다 · 여러 근사식이 공통 한계를 가질 때. "all come with the same caveat"
centered near~을 중심으로 한 · 근사가 기준점 근처에서만 유효할 때. "which point it's centered near"
stand on~위에 기반을 두다 · 다른 방법론의 토대가 될 때. "the foundation that optimization... stand on"
tolerable감내할 수 있는, 허용 가능한 · 오차의 허용 범위를 말할 때. "how much error is tolerable"
LMSR로그마켓스코어링룰(Logarithmic Market Scoring Rule) · 예측시장 AMM의 가격함수, 1차 테일러 전개로 슬리피지를 근사할 때 대상이 됨. "Expanding LMSR's price function to first order"

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

← 1036. 고정소수점 산술(Q64.96)1038. 볼록집합/볼록함수 판별 →