trendingzones

AI & ML — LAB

Vectors Lab

Set two vectors and watch every core vector operation update live — addition, subtraction, scalar multiplication, the dot product and the angle it implies, magnitude and unit vectors, and projection. This is the same math covered in Vectors & Dot Products, built as a free-form workspace instead of a fixed example.

How to Use This Lab

The Lab

What Each Operation Means

Addition & Subtraction

A + B is found by walking A, then walking B from wherever A left off. A − B is the same as A + (−B) — walking A, then walking B’s exact opposite direction.

Scalar Multiplication

Multiplying a vector by a number k stretches or shrinks it by that factor, keeping its direction the same if k is positive, or flipping it if k is negative.

Dot Product & Angle

A · B multiplies matching components and adds them up. Because A · B = |A||B|cos θ, rearranging gives the angle θ between the two vectors directly from their components — no protractor needed.

Magnitude & Unit Vector

|A| is the length of A, found with the Pythagorean theorem extended to as many dimensions as A has. Dividing A by its own magnitude produces a unit vector — same direction, length exactly 1.

Projection

Projecting A onto B answers “how much of A points in B’s direction?” — geometrically, it’s the shadow A would cast onto the line through B if light fell perpendicular to that line.

Want the full explanation behind these formulas — including why the dot product measures similarity between embeddings, and how it powers a transformer’s attention mechanism? Read Vectors & Dot Products →