Can there be a function that's even and odd at the same time?

I woke up this morning and had this question in mind. Just curious if such function can exist.


Solution 1:

Others have mentioned that $f(x)=0$ is an example. In fact, we can prove that it is the only example of a function from $\mathbb{R}\to \mathbb{R}$ (i.e a function which takes in real values and outputs real values) that is both odd and even. Suppose $f(x)$ is any function which is both odd and even. Then $f(-x) = -f(x)$ by odd-ness, and $f(-x)=f(x)$ by even-ness. Thus $-f(x) = f(x)$, so $f(x)=0.$

Solution 2:

If $K$ is a field of characteristic 2, every function $K\to K$ is both even and odd.