Since is a continuous function on , it attains a maximum on . This maximum cannot be at , since
so is locally increasing at . Similarly,
, so is locally decreasing at and cannot have a maximum at . So the maximum is attained at some
. But then by Fermat's theorem.