ForHosting KIT · Math

Dot product calculator

Enter two vectors of the same length and get their dot product, both lengths and the angle between them: [1, 2, 3] and [4, −5, 6] give 12 and an acute angle. Free in your browser.

  • Free
  • Runs in your browser
  • No sign-up
  • Your data stays on your device
Use it from WebAPIEmailTelegramApp soon
If you enter
First text
1, 2, 3
Second text
4, -5, 6
You get
N
3
Dot product
12
Magnitude a
3.7416573868
Magnitude b
8.7749643874

A dot product calculator turns two equal-length vectors into the scalar a·b, the Euclidean lengths of each vector, the cosine of the angle between them, and the angle itself in both radians and degrees. Enter vector a and vector b as arrays of finite numbers with the same dimension; the tool sums the element-wise products, takes square roots for magnitudes, and applies arccos to the clamped cosine so floating error never invents an invalid angle. Zero vectors make the angle undefined, so that case is rejected too.

What the dot product and angle mean

The Euclidean magnitude of a vector is the square root of its self-dot-product, so |a| equals the square root of a·a and |b| equals the square root of b·b. The geometric definition then says a·b equals |a| times |b| times cos θ, which rearranges to θ equals arccos of (a·b) divided by (|a||b|) whenever both magnitudes are strictly positive.

Teachers, graphics programmers, and machine-learning practitioners all care about that identity: it is the basis of projection, lighting normals, cosine similarity, and the check that two edge vectors in a mesh are perpendicular. This tool also labels the relation as orthogonal, parallel same direction, parallel opposite direction, acute, or obtuse so you can assert orientation without re-deriving thresholds yourself.

Different lengths are a hard error because the sum of products is only defined when every component has a partner—padding with zeros would change the geometric meaning and hide shape bugs in calling code.

Practical tips, limits, and related searches

Keep both vectors the same length before you call; if your source data sometimes drops a trailing zero, fix the shape upstream rather than relying on silent padding. Prefer numeric arrays over pre-formatted strings when you control the client; string forms are accepted only when every token matches a strict finite numeric pattern. Near-orthogonal floating results may still land slightly off zero after rounding—if you need a hard right angle for tests, use exact integers such as [1, 0] and [0, 1].

Prefer this capability when you already have numeric components and need a·b plus θ; if your source is a word problem, extract the two coordinate lists first.

Pre-flight cosine similarity in pipelines

Data jobs validate equal embedding lengths, compute the scalar product and angle, then branch on relation before clustering, ranking, or lighting calculations.

What happens if the vectors have different lengths?

The element-wise sum is only defined when both vectors share the same dimension.

How is the angle between vectors computed?

θ = arccos( (a·b) / (|a||b|) ), with cos θ clamped to [-1, 1] for floating safety. Results are returned in radians and degrees.

Is the dot product calculator free?

The browser tool is free and runs locally.

How do I calculate the dot product of two vectors?

Multiply the matching components and add the results. For [1, 2, 3] and [4, −5, 6] that is 4 − 10 + 18, which gives 12.

What does a dot product of zero mean?

It means the two vectors are perpendicular, at a right angle to each other. The calculator labels that case as orthogonal, and also tells you when the angle is acute, obtuse or the vectors are parallel.

Everything on this page is available programmatically. This section is for teams who want to wire it into their own systems; everyone else can just use the tool above.

POSThttps://api.kit.forhosting.com/algebra/dot-product

Prefer to automate it? One authenticated POST creates the task; the result comes back by webhook or a signed link. The same capability also runs here on the web, by email and from Telegram — and soon from our app too.

curl -X POST https://api.kit.forhosting.com/algebra/dot-product \
  -H "Authorization: Bearer $KIT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"a":[1,2,3],"b":[4,-5,6]}'
{
  "a": [
    1,
    2,
    3
  ],
  "b": [
    4,
    -5,
    6
  ]
}
{
  "task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
  "type": "algebra.dot_product",
  "status": "queued",
  "_links": {
    "result": "/tasks/tsk_…/result"
  }
}

The API is asynchronous: the call returns a task_id immediately and the result arrives by webhook. Polling is capped at 1 req/s per task.

Per request$0.002

Published price — no tokens, no invented credits. A failed task is never charged.

max_abs1000000000000
max_dim1000
HTTPCodeMeaning
401unauthorizedMissing or invalid API key.
402insufficient_balanceYour balance doesn't cover the task price.
404unknown_typeThat task type doesn't exist.
429rate_limitedToo many requests. Use the webhook instead of polling.

What the dot product and angle mean

For two real vectors a and b of the same dimension n, the dot product is the sum from i equals one to n of a_i times b_i. That single real number is positive when the vectors form an acute angle, zero when they are orthogonal (perpendicular), and negative when the angle is obtuse.

How to call the API and what comes back

Each must be a non-empty array of finite numbers, or a string that parses as a bracketed or comma-or-space-separated list of finite numbers. Send a JSON body with two required fields: a (aliases u, vector_a, vec1) and b (aliases v, vector_b, vec2). Dimensions must match exactly and must not exceed one thousand components; each absolute component value must stay within one trillion so intermediate sums of squares remain finite in IEEE double precision on the Worker and in the browser. On success the response echoes rounded a and b, sets n to the shared length, dot_product to the rounded scalar sum, magnitude_a and magnitude_b to the rounded Euclidean lengths, cosine to the clamped cos θ, angle_rad and angle_deg to the angle in both units, relation to one of the five orientation labels, formula to the defining identity string, message to a short English summary, and steps to an ordered array of substitution lines you can show in a worksheet or assert in tests. Failed validation—missing fields, non-array input, empty vectors, unequal lengths, non-finite components, values outside absolute limits, dimension above the published maximum, zero magnitude, or a non-finite intermediate—returns invalid_input and is never charged. Pricing is a flat $0.002 per successful request with unit item and zero marginal unit price.

Practical tips, limits, and related searches

Pair classic cases when teaching: [1, 2, 3] with [4, −5, 6] for a mixed-sign product and acute or obtuse angle depending on the sum; [1, 0] with [0, 1] for a pure orthogonal demo; [1, 2] with [2, 4] for parallel same direction; and deliberately unequal lengths such as [1, 2] versus [1, 2, 3] for the invalid_input path. This landing targets people searching for a dot product calculator, angle between two vectors, or cosine similarity of coordinate lists; it is not a cross-product tool (which needs three dimensions and returns a vector), not a matrix multiplication service, and not a symbolic computer-algebra system. Failed tasks that return invalid_input do not consume prepaid balance, which keeps exploratory scripts cheap when learners deliberately send mismatched lengths. Round-trip checks are easy: recompute the sum of products by hand, confirm magnitudes with a pocket calculator, and verify that angle_deg is about one hundred eighty over pi times angle_rad within the published twelve-decimal rounding.

Homework checks for vector geometry

Students enter two coordinate lists from textbook exercises and compare hand-written a·b, |a|, |b|, and θ against a deterministic JSON result before submitting.

Unit tests for graphics and physics code

Generate known-good orthogonal, acute, obtuse, and parallel pairs plus deliberate length-mismatch rejections for expected values in game engines and physics engines.

What is the dot product of two vectors?

For equal-length vectors a and b, a·b is the sum of a_i times b_i over every component. Geometrically it equals |a||b|cos θ.

Can either vector be the zero vector?

No for the angle path. A zero magnitude makes cos θ undefined, so the API rejects zero vectors with invalid_input.

Read the full KIT documentation →