Recently I started reading on Optimisation Theory and reached the section about the Weierstrass' Theorem. However, I was stuck at one of the activities which requires me to think of an example of sets and function with the following properties:
"A compact set D ⊆ R and two functions g + h : D −→ R such that neither g nor h have either a maximum or minimum on D but the sum g + h does."
I understand that if D is compact if and only if D is closed and bounded (for example, D = [1,2] is compact as it is closed and bounded). However, I couldn't think of any examples that fit into these properties.
Take$$\begin{array}{rccc}g\colon&[0,1]&\longrightarrow&\mathbb R\\&x&\mapsto&\begin{cases}(-1)^nn&\text{ if }x=\frac1n\text{ for some }n\in\mathbb N\\0&\text{ otherwise}\end{cases}\end{array}$$and $h=-g$. Then neither $g$ nor $h$ has a maximum or a minimum. But $g+h$ is the null function which has both a maximum and a minimum.