# Prove that $f$ is constant if $f(x)=f(x^2-x+1)$

Let $f:[0,1] \to \mathbb{R}$ be a function which is continuous at $x_0=1$ and which satisfies$$f(x)=f(x^2-x+1), \: \forall \: x\in [0,1]$$ Prove that $f$ is constant.

My idea is to get as much as possible from the initial equation, eventually getting a chain like $f(x)=...=f(\text{something})$, that $\text{something}$ getting to $1$ eventually, independently of $x$. This way we could apply the continuity at $1$, thus proving the claim.

With these in mind, I made the substitution $x \to 1-x$ and got $$f(1-x)=f(x^2-x+1)=f(x), \: \forall \: x \in [0,1]$$ which means that it's enough to prove that $f$ is constant on $[0,\frac{1}{2}]$ and also gives $$f(x)=f(1-x)=f(x^2-x+1)=f(x-x^2), \: \forall \: x \in [0,1]$$ From here, everything eventually came back to one of those $4$ terms above and I got stuck...

Let $g(x)=x^2-x+1$. Observe that for $x\in[0,1]$, $g(x)\geq x$. In particular, $$g(x)-x=x^2-2x+1=(x-1)^2.$$ Can you show that $\lim_{n\rightarrow\infty}g^n(x)=1$ for all $x\in[0,1]$? Then, $$f(x)=f(g(x))=f(g^2(x))=\cdots=f(g^n(x)).$$ Then, since $f$ is continuous at $1$, $$\lim_{n\rightarrow\infty}f(g^n(x))=f(1).$$
Hints on showing that $\lim_{n\rightarrow\infty}g^n(x)=1$: We know that $x,g(x),g^2(x),\dots$ is an increasing and bounded sequence. Therefore, we know that it has a limit. Suppose that $L$ is the limit. Suppose, for contradiction, that $L$ is less than $1$, can you find a contradiction? (If $x_k$ is sufficiently close to $L$, then can you show that $x_{k+1}>L$?)
Hints: Take $x_0 \in [0, 1]$ and let $x_{n+1} = x_n^2 - x_n + 1$. Then $x_{n+1} \geq x_n$ (why?) and $f(x_{n+1}) = f(x_n)$. In addition, $x_{n+1} \leq 1$, and in fact you can show $x_n \to 1$. Can you see why this proves your claim?