# Bijective Function — One-One and Onto, Examples

## TL;DR  
A bijective function is one that is both one-one (injective) and onto (surjective) — every output is reached by exactly one input, with no collisions and nothing left out. This article gives the definition, the two conditions, the one-to-one correspondence idea, the n! counting formula, the link to inverses, and six worked examples.

## What Is A Bijective Function?
A **bijective function** f:A→B is one that is **both injective (one-one) and surjective (onto)** at the same time. Concretely, every element of the codomain B is the image of **exactly one** element of the domain A — not zero (that would fail onto), not two or more (that would fail one-one). Another name for it is a **bijection**, or a **one-to-one correspondence**.

The definition rests on two ideas covered separately: the [injective function](/content/math/algebra/injective-function/index.html) (no two inputs share an output) and the [onto function](/content/math/algebra/onto-function/index.html) (every output is reached). Bijective is the conjunction; you need both, not either.

## What Are The Conditions For A Function To Be Bijective?
A function is bijective if and only if it satisfies **both** conditions below:

- **Condition 1 — one-one (injective):** if f(a)=f(b), then a=b. No two inputs collide.
- **Condition 2 — onto (surjective):** for every y∈B, there exists x∈A with f(x)=y. No output is left out.

Drop either one and the function stops being a bijection. A function can be one-one but not onto, onto but not one-one, or neither — only the functions clearing both bars are bijective.

## How Is A Bijective Function Connected To Its Inverse?
This is the question that makes bijections matter: _why does a function need to be bijective to have an inverse?_ Because the inverse has to send every output back to one input, with no ambiguity and no gaps.

- **Onto guarantees there's something to map back from** — every codomain element has a preimage, so the reverse map is defined everywhere on B.
- **One-one guarantees the reverse choice is unique** — each output came from a single input, so the reverse map knows exactly which one to return.

Put together, a function has a two-sided [inverse function](/content/math/algebra/inverse-functions/index.html) **if and only if it is bijective.** That biconditional is the whole reason the concept is taught: bijection is the precise condition for reversibility.

## What Is The Number Of Bijective Functions Between Two Finite Sets?
A bijection can only exist between sets of the **same size**. If A and B each have n elements, the number of bijective functions from A to B is:

n!=n×(n−1)×(n−2)×⋯×2×1

Each symbol: n is the common size of both sets. The first input has n output choices; the second has n−1 remaining; the third n−2; down to the last input, which has only 1 output left. If |A|≠|B|, the number of bijections is **0**. The n! count is exactly the number of ways to rearrange n items, which is why bijections from a set to itself are also called **permutations**.

## Examples Of Bijective Functions
The six examples move from a finite check through proofs to a counting problem, with one deliberate wrong turn.

### Example 1
**Decide whether f: {1, 2, 3} → {a, b, c} given by f(1)=b, f(2)=c, f(3)=a is bijective.**

Check one-one: the outputs b, c, a are all different, so no collision.

Check onto: a, b, c are all reached.

Both conditions hold, so f is **bijective**.

### Example 2
**Decide whether f: ℝ → ℝ, f(x)=x² is bijective.**

The tempting move is "x² maps reals to reals cleanly, so it pairs them off."

Check one-one first. Suppose a²=b²; this allows a=−b, so f(2)=f(−2)=4. One-one **fails**.

Check onto. The output −1 has no real preimage, since no square is negative. Onto **fails** too.

The function is **not bijective**.

### Example 3
**Prove that f: ℝ → ℝ, f(x)=3x+2 is bijective.**

One-one: assume 3a+2=3b+2.

3a=3b, so a=b. Injective holds.

Onto: take any y∈ℝ and solve 3x+2=y.

x=(y−2)/3, which is real for every y. Surjective holds.

Both conditions hold, so f is **bijective**.

### Example 4
**Decide whether f: ℝ → ℝ, f(x)=x³ is bijective.**

One-one: a³=b³ forces a=b (one real cube root each). Injective holds.

Onto: every real y has the real preimage x=y³. Surjective holds.

So f is **bijective**.

### Example 5
**Decide whether f: ℕ → ℕ defined by f(x)=x+1 if x is odd and f(x)=x−1 if x is even is bijective.**

The map swaps each odd number with its even neighbour:
1↔2, 3↔4, 5↔6, and so on.

One-one: distinct numbers land on distinct partners — no collision.

Onto: every natural number is the partner of some other, so all outputs are reached.

So f is **bijective** (it is its own inverse).

### Example 6
**Count the bijective functions from a 4-element set to a 4-element set.**

Both sets have size n=4.
n!=4!=4×3×2×1=24.

There are **24** bijections — equivalently, 24 ways to permute 4 items.

## Why Bijections Matter: "A Bijection Is A Perfect Translation"
Bijections exist because mathematics needed a precise way to say _two sets are interchangeable_ — every element of one matched with exactly one of the other, losing nothing.

- **They define "same size."** Two sets have the same number of elements precisely when a bijection exists between them.
- **They guarantee reversibility.** Encryption that must decrypt, a coordinate change that must reverse, a [rotation matrix](/content/math/algebra/rotation-matrix/index.html) that must undo a rotation — each needs a bijection so the operation can be cleanly inverted.
- **They are the permutations.** Every reshuffling of a deck of cards is a bijection from the deck to itself.

The destination this opens is set theory's comparison of infinities. [Georg Cantor](https://mathshistory.st-andrews.ac.uk/Biographies/Cantor/) used bijections to prove that no bijection exists between the integers and the real numbers — the famous diagonal argument — establishing that some infinities are bigger than others.

## Where Bijectivity Breaks Down
Three mistakes account for most wrong "is it bijective?" answers.

### Mistake 1: Checking only one condition
**Where it slips in:** problems where a function clears one bar and the student stops.

**The correct way:** check _both_. e^x is injective, but its range is (0,∞), so it misses every non-positive output and fails onto.

### Mistake 2: Ignoring the codomain
**Where it slips in:** the same formula declared with different target sets.

**The correct way:** f(x)=x² is bijective as [0,∞)→[0,∞) but not as ℝ→ℝ.

### Mistake 3: Assuming any inverse-looking formula proves a bijection
**Where it slips in:** problems where a candidate inverse is written down without checking it works both ways.

**The correct way:** a true two-sided inverse needs f(g(x))=x and g(f(x))=x.

## Conclusion
- A **bijective function** is both one-one and onto: every output is reached by exactly one input.
- Both conditions are required — checking only injectivity or only surjectivity is the most common mistake.
- A function has a two-sided inverse if and only if it is bijective.
- A bijection exists only between sets of equal size; for two n-element sets there are n! of them.
- Bijections define what it means for two sets to have the same size, even for infinite sets.
