#L02 · Linear Algebra & Manifolds · Lv.2View in 3D Mind-Map

Dot Product & Cosine Similarity

J. W. Gibbs & Oliver Heaviside · 1881 CE

a⋅b=∑i=1naibi=∥a∥∥b∥cos⁡θ\mathbf{a} \cdot \mathbf{b} = \sum_{i=1}^{n} a_i b_i = \|\mathbf{a}\|\|\mathbf{b}\|\cos\theta
sim(a,b)=cos⁡θ=a⋅b∥a∥∥b∥\text{sim}(\mathbf{a}, \mathbf{b}) = \cos\theta = \frac{\mathbf{a}\cdot\mathbf{b}}{\|\mathbf{a}\|\|\mathbf{b}\|}

Equates simple component-wise multiplication ∑ a_i b_i with geometric angle alignment ‖a‖‖b‖cos θ—powering LLM RAG vector search, Transformer Attention, and 3D lighting shaders.

🧮 Live Formula Calculator & Plotter
Vec a_x
Vec a_y
Vec b_x
Vec b_y
a⋅b=(4)(2)+(2)(4)=16.0,cos⁡θ=0.800\mathbf{a}\cdot\mathbf{b} = (4)(2) + (2)(4) = 16.0, \quad \cos\theta = 0.800
내적 a · b
16.000
코사인 유사도 cos θ
0.8000
두 벡터 사잇각 θ
36.9°
ab

Prerequisite Path (10 STEP)

Full Path Analyzer

Click steps in order to follow the 3D neon path from basics to target.

Geometric & Intuitive Insight

두 벡터가 같은 방향(0°)을 바라보면 cos θ = 1 (유사도 최대), 수직(90°)이면 내적이 0 (무관함/직교), 반대 방향(180°)이면 -1 이 됩니다. 게임에서 적이 내 시야각 안에 있는지, 태양빛이 표면에 얼마나 수직으로 비치는지 단 한 줄로 판별합니다!

Step-by-Step Derivation

  1. Step 1.1단계: 두 벡터 a, b와 차이 벡터 (a - b)가 이루는 삼각형에 제2코사인법칙을 적용합니다 → ‖a - b‖² = ‖a‖² + ‖b‖² - 2‖a‖‖b‖cos θ
  2. Step 2.2단계: 좌변을 성분별로 전개하면 ∑(a_i - b_i)² = ∑a_i² + ∑b_i² - 2∑a_i b_i 입니다.
  3. Step 3.3단계: 양변의 ‖a‖² + ‖b‖² 을 소거하고 -2로 나누면 ∑ a_i b_i = ‖a‖‖b‖cos θ 가 완벽히 증명됩니다.

AI & Coding Real-World Use

LLM Transformer Attention (Q·K^T), RAG vector DB cosine search, and 3D Lambertian lighting (N·L)

#LLM Self-Attention Q·K#RAG Vector DB#3D Lighting Shader
const cosSim = (a:number[], b:number[]) => dot(a,b) / (norm(a) * norm(b));

Linear Algebra & Manifolds — Related Formulas in This Cluster