What is the thought process on defining a new function in Intermediate Value Problems? I have no clue on where my lecturer is getting the function g from. I'm assuming it somehow comes from the absolute value condition:

Is there a way to solve this problem without defining a new function?
 A: Here is how you would go about coming up with this yourself. I will rewrite the problem statement for clarity since the problem was provided in a linked image.
Problem. If $f : [0,1] \to \mathbb{R}$ is a continuous function such that $f(0) = f(1)$. Show that there exist $p,q \in [0,1]$ with $|p-q| = \frac{1}{2}$ and $f(p) = f(q)$.
You know (presumably?) you want to apply the Intermediate Value Theorem, which guarantees the existence of a particular argument of the function with a given value. Here we want two values, $p,q$, but they are related via $|p-q|=\frac{1}{2}$, so that either $p - q = \frac{1}{2}$ or $q - p = \frac{1}{2}$. From the symmetry in the problem we can assume without loss of generality that it is the latter, so $q = p + \frac{1}{2}$. Thus, we may rewrite the conclusion as saying that we want a point $p$ such that both $p,p+\frac{1}{2} \in [0,1]$ and $f(p) = f(p+\frac{1}{2})$. This reduces it to the existence of a single point $p$.
The conditions $p,p+\frac{1}{2} \in [0,1]$ forces $p \in [0,\frac{1}{2}]$, and we can rewrite the equality as $f(p) - f(p+\frac{1}{2}) = 0$. Now the conclusion matches the form of the Intermediate Value Theorem, but the function in question is $g(x) = f(x) - f(x+\frac{1}{2})$, with $g : [0,\frac{1}{2}] \to \mathbb{R}$. Consequently, it is this $g$ we need to check is continuous and that $g(0),g(\frac{1}{2})$ have opposite signs, hence your lecturer's proof.
A: The idea behind the proof is that we want to compare the values of $f$ at points that are a distance of $\frac 1 2$ apart. So let’s consider $f$ at pairs of points $(a,b)$ where $b=a+ \frac 1 2$and $a$ goes from $0$ to $\frac 1 2$.
If $f(0)=f(\frac 1 2)$ then we are done. So let’s suppose $f(\frac 1 2) > f(0)$ so that initially $f(b) = f(\frac 1 2) > f(0) = f(a)$. But when we slide our pair of points to the other end of the interval we have $f(b) = f(1) < f(\frac 1 2) = f(a)$, so $f(a)$ has “overtaken” $f(b)$.  We can argue from continuity that there must be some intermediate point where $f(b)=f(a)$. And if $f(\frac 1 2) < f(0)$ we can use the same argument starting at $a=\frac 1 2$ and sliding backwards to $a=0$.
The function $g$ is just introduced to formalise this argument.
You might like to consider why the property of continuity is important by trying to find a non-continuous function that does not have this property.
