### Instruction: Let $f(x)$ be a function such that $f(0) = 1$ and
\[f(xy) = f \left( \frac{x^2 + y^2}{2} \right) + (x - y)^2\]for all real numbers $x$ and $y.$  Find $f(x).$.### Response: This is a functional equation, so I want to find a way to simplify it or make it easier to work with.
I notice that the equation involves both multiplication and addition of $x$ and $y,$ so maybe I can try some special values of $x$ and $y$ that make one or both of those operations simpler.
For example, what if I let $y = 0?$ Then the equation becomes $f(0) = f \left( \frac{x^2}{2} \right) + x^2.$
Since I know that $f(0) = 1,$ I can subtract $x^2$ from both sides and get $1 - x^2 = f \left( \frac{x^2}{2} \right).$
This looks like a simpler expression for $f(x),$ but it only works when $x$ is a square root of twice some other number.
To make it more general, I can let $x = \sqrt{2z}$ for any real number $z.$
Then I get $1 - 2z = f(z),$ which is a linear function of $z.$
Therefore, I can write $f(x) = 1 - 2x$ for any real number $x.$
To check if this is a valid solution, I can plug it back into the original equation and see if it satisfies it.
So I have $1 - 2xy = 1 - 2 \left( \frac{x^2 + y^2}{2} \right) + (x - y)^2.$
Simplifying, I get $-2xy = -x^2 - y^2 + (x - y)^2.$
Expanding the last term, I get $-2xy = -x^2 - y^2 + x^2 - 2xy + y^2.$
Cancelling out the terms that are equal and opposite, I get $-2xy = -2xy.$
This is true for any real numbers $x$ and $y,$ so I have verified that $f(x) = 1 - 2x$ is a solution.