Cartesian Product Calculator
Enter the elements of set A and set B, separated by commas.
Result
How it is calculated
Type the elements of each set separated by commas. The tool trims spaces around each element, ignores empty entries (so a doubled comma is harmless) and treats every element as plain text. Because a set has no repeats, identical entries are merged first, and the comparison is case-sensitive, so a and A stay separate. It then pairs each element of A with each element of B, in order, writing every pair as (a, b). The number of pairs is |A| × |B|, the size of A multiplied by the size of B, counted after merging, and the tool also prints both sizes. If either set ends up empty there is no result. Order matters: (a, b) and (b, a) are different pairs, so A × B and B × A hold the same pairs written the other way round.
Worked example
Set A is the colours red, green, blue (3 elements) and set B is the sizes S, M (2 elements). Each colour is paired with each size, colour first: (red, S), (red, M), (green, S), (green, M), (blue, S), (blue, M). The count is 3 × 2 = 6 pairs. This is the same list a shop would need for every colour and size combination of one product, and swapping the sets would give pairs with the size first instead.
Common mistakes
- Separating elements with spaces or semicolons instead of commas.
red green blueis read as a single element, giving 1 × |B| pairs. - Repeating an element and expecting it to count twice.
a,a,bis merged to the two elements a and b, so |A| = 2, not 3. - Expecting
aandAto be merged. They are compared exactly, so both stay and the pair count grows. - Entering elements that contain commas, such as
Smith, John. The comma splits them into two separate elements. - Treating the result as unordered pairs. A × B lists (a, b) with a from A first; (b, a) belongs to B × A.
About this calculator
The Cartesian product of two sets A and B, written A × B, is the set of every possible ordered pair (a, b) where a comes from A and b comes from B — if A has m elements and B has n elements, the product has exactly m×n pairs. This calculator takes two comma-separated lists, generates every ordered pair between them, and reports the total pair count.
The concept is foundational across discrete mathematics, combinatorics and computer science: it's how a plane's coordinate grid (ℝ × ℝ) is formally defined, how programmers reason about nested loops that iterate over two collections, and — perhaps most practically — the mathematical basis of the SQL CROSS JOIN, where a database engine pairs every row of one table with every row of another. Students meet it early in set theory courses as the building block for relations and functions, since any relation between two sets is technically defined as a subset of their Cartesian product.
Was this helpful?
You can pick up to 3 reactions.
Popular calculators
Loan Calculator
Monthly payment, total interest and full amortization schedule.
Percentage Calculator
Percent change, percent of, and ratio calculations.
Discount Calculator
Calculate final price, savings, and discount amount.
BMI Calculator
Body mass index from height and weight (metric or imperial).
Age Calculator
Compute your exact age in years, months and days from a birth date.
Compound Interest Calculator
Calculate the final amount and interest earned with compounding.
All Calculators
- Loan Calculator
- Profit Calculator
- Discount Calculator
- BMI Calculator
- Percentage Calculator
- Ideal Weight Calculator
- Age Calculator
- Pregnancy Due Date Calculator
- Compound Interest Calculator
- BMR Calculator (Basal Metabolic Rate)
- Tip Calculator
- Fuel Cost Calculator
- Date Difference Calculator
- Sleep Cycle Calculator
- Daily Water Intake Calculator
- Simple Interest Calculator
- Heart Rate Zones Calculator
- Running Pace Calculator
- Pet Age Calculator
- Calories Burned Calculator
- Macro Calculator
- TDEE Calculator (Total Daily Energy Expenditure)
- Waist-to-Hip Ratio Calculator
- Honor Roll Calculator
- One Rep Max (1RM) Calculator
- Ovulation Calculator
- Electricity Cost Calculator
- Unit Price Calculator
- Savings Goal Calculator
- Break-Even Point Calculator
- Paint Calculator
- Course Grade Average Calculator
- Business Days Calculator
- Time Duration Calculator
- Fuel Economy Calculator
- Temperature Converter
- Tile Calculator
- Aspect Ratio Calculator
- Roman Numeral Converter
- Goal Weight Timeline Calculator
- Salary Converter (Hourly to Annual)
- Credit Card Validator (Luhn)
- Body Surface Area (BSA) Calculator
- Feels-Like Temperature Calculator
- Ohm’s Law Calculator
- PPI (Pixel Density) Calculator
- Molar Mass Calculator
- Zodiac Sign Calculator (Western + Chinese)
- IBAN Validator
- Shoe Size Converter
- Country Info & Dialing Code Lookup
- Time Zone Difference (World Clock)
- CAGR (Compound Annual Growth Rate) Calculator
- Rule of 72 Calculator
- Blood Alcohol Content (BAC) Calculator
- Lean Body Mass (LBM) Calculator
- Pythagorean Theorem Calculator
- Speed Converter
- Download Time Calculator
- Date Calculator (Add/Subtract)
No calculators found
Comments (1)
The pair count multiplies, which is the quick way to size a test plan before you list anything. Four browsers against six screen sizes is 24 combinations, and adding a third dimension later would multiply again. Order matters here, so (a, b) and (b, a) are different pairs. Duplicate entries are merged first. What are you combining: menu options, test cases, or something else?