Tensor product calculator
Two 2×2 matrices give a 4×4 Kronecker product made of scaled copies of the second one. Enter both matrices as rows of numbers and get A⊗B with the size of each factor, even when their shapes do not match. Free in your browser.
- Free
- Runs in your browser
- No sign-up
- Your data stays on your device
Run — free
The Kronecker tensor product of two matrices is the block matrix you obtain by scaling the entire second factor by every entry of the first. Students meet this construction in multilinear algebra, quantum information (two-qubit operators written as products of single-qubit gates), graph theory (Kronecker products of adjacency matrices), and discrete signal processing (separable filters). This calculator accepts two rectangular matrices as rows of finite numbers, builds the Kronecker product with a deterministic four-index loop, and returns the product matrix together with the factor shapes.
What the Kronecker tensor product is — and what it is not
The Kronecker product is a block construction, not a row-column inner product. Write A as an m by n table of numbers and B as a p by q table. Order matters: A tensor B and B tensor A have the same entries only after a known shuffle of rows and columns, and they are equal as matrices only in special cases such as when both factors are one-by-one.
A classic integer check is the pair A equals [[1, 2], [3, 4]] and B equals [[0, 5], [6, 7]], whose Kronecker product is the four-by-four matrix with first row [0, 5, 0, 10] and last row [18, 21, 24, 28]. This calculator implements exactly that textbook block rule, rounds each published entry to the requested precision, and refuses to invent a result when a cell is missing, jagged, or non-finite.
Where the Kronecker product is used
Classrooms and tutoring platforms use a Kronecker tensor product calculator so learners can check a block construction without expanding every scaled copy of B by hand and without confusing the operation with the ordinary product A times B. Exam-prep generators need a deterministic oracle that marks a non-finite cell as an error instead of returning a matrix that contains NaN, which a buggy grader might treat as a near-miss.
Signal-processing and imaging scripts build separable kernels the same way, and graph algorithms that take the Kronecker product of adjacency matrices need an explicit, documented path for modest integer examples. Failed validation does not consume balance. Keep requests inside the twenty-by-twenty input limit and the two-hundred-by-two-hundred product ceiling, pin the rounded product in tests, and you get reproducible Kronecker matrices for homework, LMS plugins, and edge workers without standing up symbolic math infrastructure of your own.
What you can do with it
Homework and exam answer keys
Build A⊗B for textbook integer matrices, check the (m·p)×(n·q) shape, and verify each block against a hand-scaled copy of B.
Quantum, graphs, and separable kernels
Compose two-qubit operators, Kronecker graphs, or separable filters when both factors fit the published row and column limits.
FAQ
How is the Kronecker tensor product different from ordinary matrix multiplication?
Ordinary multiplication needs columns of A to equal rows of B and produces an m×p matrix of row-column dots. The Kronecker product A⊗B is always defined for rectangular A and B: it tiles scaled copies of B and has shape (m·p)×(n·q).
What happens if a matrix contains Infinity or NaN?
Every entry of both factors must be a finite number; non-finite values are not billed and never appear in a product.
Does A⊗B equal B⊗A?
Not in general. The two products contain the same numbers after a known permutation of rows and columns, but they are equal as matrices only in special cases. This tool always computes A⊗B in that order.
What size matrices are supported?
Each factor may have up to 20 rows and 20 columns. The product is rejected if it would exceed 200 rows or 200 columns.
Do the two matrices need matching sizes for a Kronecker product?
No. Unlike ordinary multiplication, any two rectangular matrices can be combined, so a 2×3 matrix works with a 1×2 row. If A has m rows and n columns and B has p and q, the result has m·p rows and n·q columns.
Related tools
For developers — API access
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.
API endpoint
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.
Call it from your stack
curl -X POST https://api.kit.forhosting.com/math/tensor-product \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"a":[[1,2],[3,4]],"b":[[0,5],[6,7]]}'const res = await fetch("https://api.kit.forhosting.com/math/tensor-product", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"a": [
[
1,
2
],
[
3,
4
]
],
"b": [
[
0,
5
],
[
6,
7
]
]
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/math/tensor-product",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"a": [
[
1,
2
],
[
3,
4
]
],
"b": [
[
0,
5
],
[
6,
7
]
]
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/math/tensor-product", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"a":[[1,2],[3,4]],"b":[[0,5],[6,7]]}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"a":[[1,2],[3,4]],"b":[[0,5],[6,7]]}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/math/tensor-product", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("KIT_KEY"))
req.Header.Set("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)Example request
{
"a": [
[
1,
2
],
[
3,
4
]
],
"b": [
[
0,
5
],
[
6,
7
]
]
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "math.tensor_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.
Pricing
Published price — no tokens, no invented credits. A failed task is never charged.
Limits
max_rows | 20 |
max_cols | 20 |
max_product_rows | 200 |
max_product_cols | 200 |
max_abs_entry | 1000000000000 |
Errors
| HTTP | Code | Meaning |
|---|---|---|
401 | unauthorized | Missing or invalid API key. |
402 | insufficient_balance | Your balance doesn't cover the task price. |
404 | unknown_type | That task type doesn't exist. |
429 | rate_limited | Too many requests. Use the webhook instead of polling. |
Technical notes
If A is m by n and B is p by q, A tensor B is the (m times p) by (n times q) matrix whose (i, j)-th block is a_ij times B. A non-finite cell is rejected as invalid_input rather than silently becoming NaN or Infinity. No network, no randomness, and a contract you can pin in tests at $0.002 per successful call.
What the Kronecker tensor product is — and what it is not
Then A tensor B is the tall, wide matrix obtained by replacing each entry a_ij of A with the entire scaled block a_ij times B. The result therefore has m times p rows and n times q columns, and the entry at row i times p plus r and column j times q plus c is exactly a_ij times b_rc. That definition does not require the inner dimensions of A and B to match: a two-by-three matrix may be tensored with a one-by-two row, or a column with a square, and the product is always defined as long as both factors are rectangular and finite. That is the first contrast with ordinary matrix multiplication, which is undefined unless columns of A equal rows of B. It is also not the Hadamard product, which multiplies matching entries and requires identical shapes, and it is not the Khatri–Rao or Kronecker-sum constructions that appear in other corners of multilinear algebra.
Input contract, response shape, and how non-finite entries fail
Field a is the left factor: a non-empty array of rows, each row a non-empty array of finite numbers, all rows the same length so the matrix is rectangular. Field b is the right factor in the same row-major form. Optional precision between zero and fifteen decimal places rounds every published product entry; the default is ten. There is no silent coercion of null to zero and no broadcasting of a scalar into a matrix. Failed validation is not billed. POST a JSON body with two required matrices. Aliases matrix_a, left, and A for the first factor and matrix_b, right, and B for the second are accepted so spreadsheets, query strings, and typed forms can reuse the same contract. Each cell may arrive as a JSON number or as a numeric string; empty strings, objects, and tokens that are not finite (Infinity, NaN, or a string that does not parse to a finite decimal) fail with invalid_input that names the offending field path, for example a[1][0]. Inputs are capped at twenty rows and twenty columns each, and the product is rejected if it would exceed two hundred rows or two hundred columns, so a single request stays inside a Worker isolate even though the Kronecker shape multiplies the factor dimensions. On success the body returns product as the block matrix in the same nested-array form, the echoed factors a and b, the four shape numbers rows_a, cols_a, rows_b, and cols_b, the product dimensions, the precision used, a short formula string documenting the four-index rule, and the published input maxima. Pair the response with your own typesetting if you need prettyprinted Kronecker brackets; this endpoint returns JSON numbers only and does not emit plots or symbolic rewrite steps.
Where a Kronecker product API earns its keep
Quantum-information notebooks write two-qubit operators as Kronecker products of single-qubit matrices; a tiny parse API lets a lesson page verify X tensor I or H tensor H without pulling a full computer-algebra system.
Integration use cases
Deterministic CI fixtures
Generate reproducible Kronecker products for unit tests without hand-maintaining four-index expansions or non-finite checks.
Technical questions
What does the tensor product calculator cost?
The browser tool is free. API requests use prepaid KIT balance at $0.002 per successful call; invalid input is not billed.