Small and cute functional equation: $f(f(x)) = x^2 - x + 1$

2026-01-22

Problem statement

The statement of the problem is quite mundane and short, nothing that a well-versed middle school student would fail to comprehend.

Assume that $f(f(x)) = x^2 - x + 1$ holds for all $x$. Find the value of $f(0)$.

Solution

First immediate observation that we can get by direct computation is that $f(f(0)) = f(f(1)) = 1$. Denote $y := f(0)$ and $z := f(1)$.

Now $f(f(z)) = z^2 - z + 1 = z = f(1)$. Solving this quadratic equation ($(z - 1)^2 = 0$) we get that $z = f(1) = 1$.

We also have that $f(f(y)) = f(1) = 1 = y^2 - y + 1$. This leads us to another quadratic equation ($y(y - 1) = 0$) which has two roots, $y = 0$ and $y = 1$. However, the case $y = 0$ is impossible, otherwise we would have that $f(f(0)) = f(0) = 0$, which is in contrary to the initial assumption $f(f(0)) = 1$.

Thus we can finally conclude that the only possible solution to this problem is $$ f(0) = 1. $$