Suppose $f$ is continuous on $[-1;1]$ such that $x^2 +f^2(x) = 1$ for all $x$. Show that $f(x) = \sqrt{1-x^2}$ or $f(x) = -\sqrt{1-x^2}$ for all $x$ Suppose $f$ is continuous on $[-1;1]$ such that $x^2 +f^2(x) = 1$ for all $x$. Show that $f(x) = \sqrt{1-x^2}$ or $f(x) = -\sqrt{1-x^2}$ for all $x$

This is my idea:
$x^2 + f^2(x) = 1 \Leftrightarrow f^2(x) = 1-x^2 $, for $x\in[-1;1] (*)$
So: With $(*)$, we can generally conclude the value of $f$ on $[-1;1]$:
$f(x) = \begin{cases} \sqrt{1-x^2} &x\in K\\ -\sqrt{1-x^2} &x\in [-1;1]\setminus K \end{cases}$
given some K satisfying $\emptyset \subseteq K \subseteq [-1;1]$ and $f$ is continuous on $[-1;1]$
(So, if $K$ contains some point $x_0$ that is not $\pm1$ then it also has to contain all points that are close to $x_0$ )
If we choose $K$ such that $K$ and $([-1;1]\setminus K$) contains at least one point that is not $\pm 1$, say respectively $c$ and $d$, we clearly have $f(c)>0>f(d)$. But since $f$ is continuous on $[c;d]$ or $[d;c]$, $\exists y\in[c;d]$ or $y\in[d;c]: f(y) = 0$, which is impossible due to the fact that $\forall x \in[c;d]$ or $[d;c]$ $\subset [-1;1]: f(x) \neq 0$. This case is not feasible.
So, we must have $K$ or ($[-1;1]\setminus K$) contains only $-1$ or $1$ or both or be empty. What if we choose $K = \text{{$1$}}$ ? By that, we still have $\text{$f$ is continuous on} [-1;1]$ and we don't seem to able to use the above argument to prove such a case is absurd.
So, shouldn't we add to hypothesis the fact that $f(-1), f(1)\neq 0$. What's wrong here ?
 A: As already said in the comments, $f(-1) = f(1) = 0$ always holds. But your argument works if you apply it to
$$
 K = \{ x \in (0, 1) \mid f(x) = \sqrt{1-x^2} \} 
$$
and $(0, 1) \setminus K$.
One can also use a connectedness argument: Use the continuity of $f$ to show that both
$$
 K = \{ x \in (0, 1) \mid f(x) > 0 \} \\
 K' = \{ x \in (0, 1) \mid f(x) < 0 \} 
$$
are open. Since $(0,1) = K \cup K'$ is connected, one of them must be empty.
The latter approach works also in the more general case where the domain of the function is a connected subset in $\Bbb R^n$ (or any topological space), when the intermediate value property can not be applied:

Let $U \subset \Bbb R^n$ be connected and $f: U \to \Bbb R$ continuous. If $f(x) \ne 0$ for all $x \in U$ then either $f(x) > 0$ for all $x \in U$ or $f(x) < 0$ for all $x \in U$.

A: Why not just to proceed without appealing to the set $K$? I would proceed in this way:
Case 1. Suppose that there is a $x_0\in[-1,1]$ such that $f(x_0)\neq -\sqrt{1-x_0^2}$.
We shall prove that for all $x\in[-1,1],$ we have $ f(x)=\sqrt{1-x^2}$. So, let $x\in [-1,1]$. If $x=-1$ or $x=1,$ then $f(x)=0=\sqrt{1-x^2}.$ Suppose now that $x \in (-1,1)$. By contradiction, assume that $f(x)=-\sqrt{1-x^2}$. We have that $f(x)<0$, since $-1<x<1$. On the other hand, $x_0$ cannot be equal to $-1$ or $1$ (otherwise, $f(x_0)=-\sqrt{1-x_0^2}=0$). Then, $-1<x_0<1$. Then, we must have $f(x_0)>0>f(x)$. Apply the continuity argument that you used before to conclude the existence of some $y\in (-1,1)$ such that $f(y)=0$. A contradiction. Then it should be $f(x)=\sqrt{1-x^2}$ for all $x$.
Case 2. Suppose thay for all $x\in[-1,1]$, we have $f(x)=-\sqrt{1-x^2}$. Then we are done.
