AI Grounds
Open AI Grounds on a desktop
These interactive lessons need a larger screen. Please continue on a desktop or laptop computer.
AI Grounds
These interactive lessons need a larger screen. Please continue on a desktop or laptop computer.
Guided discovery
Move vectors; separate length from alignment.
Two signed 2D vectors from the same origin. Magnitude is length; direction is where a nonzero arrow points. Equal axis scales preserve geometry. Select A or B to move its one active handle; coincident tips retain both identities.
● A: solid arrow■ B: dashed arrow◇ Selected tip
Select A or B; drag its active handle, or focus it and use arrows (Shift: two units). Up increases Y; Right increases X. Home sets the selected vector to (0,0); End sets (5,5). Enter or click focuses Selected vector X. Selecting a vector alone changes no values.
Signed horizontal component of B, −5..5 in whole units. Use arrow keys on the slider. Press Enter or leave the number field to apply an exact edit.
Signed vertical component of B, −5..5 in whole units. Use arrow keys on the slider. Press Enter or leave the number field to apply an exact edit.
Angled pair · A (1, 2), B (2, 1) · Dot 4.000000 · Cosine 0.800000 · Angle 36.869898°
| Vector | X | Y | Squared length | Magnitude |
|---|---|---|---|---|
| A | 1 | 2 | 5 | 2.236068 |
| B | 2 | 1 | 5 | 2.236068 |
Dot = (1)×(2) + (2)×(1) = 2.000000 + 2.000000 = 4.000000
Length product = sqrt(5 × 5) = 5.000000. Cosine = dot / length product = 0.800000; angle = acos(cosine) = 36.869898°.
Sum of signed coordinate products.
4
AxBx + AyBy
Combines length and alignment; remains defined at zero.
Alignment ratio for two nonzero vectors.
0.800
dot / (magnitude A × magnitude B)
−1 opposite; 0 perpendicular; +1 same direction.
Angle between two nonzero directions.
36.870°
acos(cosine), in degrees
Zero vector has no direction or geometric angle.
An embedding is a numeric vector representation of an item. In more dimensions, dot sums all matching component products; magnitude uses all squared components. Cosine uses the same nonzero-length ratio. These editable coordinates illustrate the algebra; they are not learned word embeddings. Whether geometric similarity tracks task meaning depends on the representation and evaluation.
Each component is an integer from −5 to 5. Both axes have equal numerical weight and equal visual scale. Vector to edit selects one active handle and two native component editors; the other vector stays fixed. Coincident endpoints retain both arrow styles, tip glyphs, an A/B label and separate exact table rows. Zero vectors have no direction arrowhead. Scenario changes restore the named pair and select B. Prediction changes/Reset restore the current step; numeric/preset edits clear stale explanations.
Dot = AxBx+AyBy, magnitudes sqrt(Ax²+Ay²) and sqrt(Bx²+By²). Cosine is dot/sqrt(aa×bb), where aa/bb are squared magnitudes. A zero squared magnitude makes the geometric ratio and angle undefined. For nonzero vectors, cosine stays in −1..1; only floating error in the ratio is clamped before acos. A positive nonzero scalar changes magnitude and dot by the same factor, preserving cosine. Negative scaling reverses direction and can reverse cosine; zero makes it undefined.
Cosine zero means perpendicular only when both vectors are nonzero. Cosine one means same direction, not necessarily equal coordinates or lengths; minus one means opposite directions. None is a class probability, semantic truth or accuracy guarantee. SciPy’s linked cosine function computes distance 1−similarity; this lesson displays similarity itself. Library-specific zero conventions do not give a zero vector a geometric direction.
The toy excludes learned embeddings, model training/inference, arbitrary dimensions, projections, reduction, retrieval evaluation, automatic policy choice and learned feature weights. The same algebra generalizes to larger vectors, while task meaning requires additional evidence.
NumPy · Dot products