2-Variable K-Map
The smallest Karnaugh map: 4 cells for the variables A and B. Solve your own map below, then see how the layout and grouping work.
Every cell not listed as a maxterm or don't-care is a 1.
Tap an output to cycle 0 → 1 → X.
Operators: ' ! ~ NOT · AB & * · AND · + | OR · ^ ⊕ XOR ·
nand, nor, xnor, ->, <->. Variables are sorted (A, B, C…) unless you write F(C,B,A) = ….
Click or tap a cell to change it. Keyboard: Tab to the map, arrows move, Enter or Space cycles, 0 / 1 / X set the value. Small numbers are minterm numbers.
Minimal SOP (sum of products)
F = A' + B
Minimal POS (product of sums)
F = A' + B
Step-by-step solution
1. Groups on the map (SOP)
The 1s are covered by 2 groups. In each product term, a variable that stays 1 across the group appears as is and one that stays 0 appears complemented. Hover or tap a term to highlight its group.
-
A' group of 2 · cells 0, 1 · pattern
0–essentialA = 0 in every cell; B changes inside the group and drops out. It is essential: m0 is covered by no other prime implicant.
-
B group of 2 · cells 1, 3 · pattern
–1essentialB = 1 in every cell; A changes inside the group and drops out. It is essential: m3 is covered by no other prime implicant.
2. Prime implicants and essential primes
Each row is a prime implicant (a group that cannot be made larger). A ⊗ marks a minterm covered by a single prime: that prime is essential (*) and must be in every minimal answer.
| Prime | Term | Pattern | m0 | m1 | m3 |
|---|---|---|---|---|---|
| P1 * | A' | 0– | ⊗ | × | |
| P2 * | B | –1 | × | ⊗ |
Essential: P1, P2. The essential primes cover everything.
3. Petrick's method: choosing the cheapest cover
Not needed: the essential prime implicants already cover every required cell, so the answer is unique.
4. Quine–McCluskey tabulation
Cells are sorted by their number of 1 bits. Two entries in neighboring groups combine when their patterns differ in exactly one position (that position becomes –). ✓ = combined further; PI = could not be combined, so it is a prime implicant.
Groups of 1
| 1s | Cells | Pattern | |
|---|---|---|---|
| 0 | 0 | 00 | ✓ |
| 1 | 1 | 01 | ✓ |
| 2 | 3 | 11 | ✓ |
Groups of 2
| 1s | Cells | Pattern | |
|---|---|---|---|
| 0 | 0,1 | 0– | PI |
| 1 | 1,3 | –1 | PI |
5. Truth table, Σm, ΠM and canonical forms
| # | A | B | F |
|---|---|---|---|
| 0 | 0 | 0 | 1 |
| 1 | 0 | 1 | 1 |
| 2 | 1 | 0 | 0 |
| 3 | 1 | 1 | 1 |
Minterm list: F = Σm(0, 1, 3)
Maxterm list: F = ΠM(2)
Canonical SOP (one term per 1): A'B' + A'B + AB
Canonical POS (one clause per 0): A' + B
Row number = minterm number, with A as the most significant bit.
6. Logic circuit (AND–OR)
Two-level AND–OR realization: one AND gate per term (a single-literal term is wired straight through), then one OR gate. 2 gates including inverters, 2 gate inputs. Replacing every AND and the final OR with NAND gates gives the equivalent NAND–NAND circuit with the same wiring (single-literal terms then need their complement).
Layout and cell numbers
Rows are labeled by A (0, 1) and columns by B (0, 1). The number in each cell is the minterm number, the decimal value of AB read as a binary number.
| A \ B | 0 | 1 |
|---|---|---|
| 0 | m0 | m1 |
| 1 | m2 | m3 |
Worked example: F = Σm(1, 2, 3)
Three cells are 1: m1 (A′B), m2 (AB′) and m3 (AB). The bottom row (A = 1) is a pair, and the right column (B = 1) is a pair. Both groups share m3, which is allowed.
- A: group of 2 (m2, m3), essential. A = 1 in every cell; B changes inside the group and drops out.
- B: group of 2 (m1, m3), essential. B = 1 in every cell; A changes inside the group and drops out.
Result: F = A + B, 2 terms and 2 literals. Open this example in the solver.
Algebraically: A′B + AB′ + AB = A(B′ + B) + B(A′ + A) = A + B, using AB twice (X = X + X).
All 16 two-variable functions
There are 24 = 16 possible functions of two variables, and every one of them has a minimal SOP of at most two terms: 0, 1, A, B, A′, B′, AB, AB′, A′B, A′B′, A + B, A + B′, A′ + B, A′ + B′, and the two that do not simplify at all, AB′ + A′B (XOR) and AB + A′B′ (XNOR), whose 1s sit on a diagonal.
Frequently asked questions
How many cells does a 2-variable K-map have?
Four, one for each combination of A and B: m0 (A = 0, B = 0), m1 (0, 1), m2 (1, 0) and m3 (1, 1). They are arranged in a 2×2 grid with A on the rows and B on the columns.
What groups are possible in a 2-variable K-map?
A single cell (2 literals, e.g. AB′), a pair in a row or column (1 literal: A, A′, B or B′), or all four cells (the constant 1). There are no diagonal groups: m0 and m3 differ in both variables.
Is a 2-variable K-map worth using?
It is mostly a teaching step: with two variables you can usually see the answer from the truth table. It shows the key idea in the smallest form: two neighboring 1s merge and the variable that changes disappears.
Related tools and guides
- 3-variable K-map Solve a 3-variable Karnaugh map (A, BC) online. Gray-code layout, cell numbers, wrap-around groups and worked examples in SOP and POS.
- 4-variable K-map Solve a 4-variable Karnaugh map (AB, CD) with don't-cares. Cell numbering, edge and corner groups, worked examples and all minimal answers.
- How to solve a K-map How to solve a Karnaugh map in 6 steps, with worked 3- and 4-variable examples, a cyclic map with two answers, and the mistakes that cost marks.
- Logic gates All seven logic gates (AND, OR, NOT, NAND, NOR, XOR, XNOR) with ANSI and IEC symbols, truth tables, expressions and NAND/NOR-only circuits.