Considering a function $$f(x)$$ defined in an closed interval $$[a,b]$$, we say that it is a continuous function if the function is continuous in the whole interval $$(a,b)$$ (open interval) and the side limits in the points $$a, b$$ coincide with the value of the function.

In other words: $$$\displaystyle \lim_{x \to p^{\pm}}f(x)=f(p) \mbox{ for any point }p \mbox{ in the open interval } (a,b) \\ \lim_{x \to a^+} f(x)=f(a) \mbox{ and } \lim_{x \to b^-}f(x)=f(b)$$$

Logically, we expect the side limits to coincide with the value of the function from one side since the function is not defined outside the interval $$[a,b]$$ and it makes no sense to speak about the side limit from the left of the function at point $$a$$ or its corresponding limit in $$b$$.

Let's study the continuity of the function $$f(x)=x^2-1$$ where $$x$$ is inside the interval $$[0,1]$$.

Continuity in $$(0,1)$$: $$$\begin{array}{l} \lim_{x \to a^+}x^2-1 = (a^+)^2-1=a^2-1 \\ \lim_{x \to a^-}x^2-1 = (a^-)^2-1=a^2-1\\ f(a)=a^2-1\end{array}$$$ therefore the function is continuous in the open interval $$(0,1)$$.

Let's look now at what happens at the extremes: $$$\displaystyle \begin{array}{l} \lim_{x \to 0^+}x^2-1 = -1 \mbox{ and } f(0)=-1 \\ \lim_{x \to 1^-}x^2-1=0 \mbox{ and } f(1)=0 \end{array}$$$ and we observe that the limits and the function coincide. So the function is continuous at the extremes.

Consequently, the function is continuous in the interval $$[0,1]$$.

## Theorem of Weierstrass

Let $$f(x)$$ be a continuous function defined in an interval $$[a,b]$$.

Then there exist two points $$x_{max}$$ and $$x_{min}$$ belonging to the interval $$[a,b]$$ where the function $$f(x)$$ reaches absolute extreme values (a maximum and an absolute minimum), so that: $$f(x_{min}) \leq f(x) \leq f(x_{max})$$ for any $$x$$ belonging to the interval $$[a,b]$$.

This theorem can look like a property since it is very intuitive.The fact that if you have a continuous function defined in a closed interval there will always exist a maximum and an absolute minimum of the function seems obvious.

We observe that if our function $$f(x)$$ does not have relative maximum (or relative minimum) it will mean that the absolute maximum (or the absolute minimum) will be located at one of the extremes of the interval (or in both).

If our function has relative maximums or minimums, we will also have to compare the values with the value of our function at the extremes of the interval, since it might be that this value was also the absolute maximum or minimum.

Let's see some examples:

Let the function $$f(x)=x$$ be defined in the interval $$[1,4]$$.

The function $$f(x)=x$$ is a strictly increasing function, so the maximum is reached at the highest point of the interval, which is $$x=4$$.

For the same reason, it reaches the minimum in the minimal point of the interval ($$x=1$$).

Let the function $$f(x)=-x^2+1$$ be defined in the interval $$[-2,1]$$.

This function has a relative maximum at point $$x=0$$, and, as there is no another maximum within the given interval, this is the absolute maximum.

On the other hand, there is no relative minimum, so the absolute minimum will be at one of the extremes of the interval.

In this case $$f(-2)=-1$$ and $$f(1)=0$$, so we have an absolute minimum at $$x =-2$$.

Observation: The theorem is not true if we do not have a closed interval.

Let's see an example where the theorem is not satisfied.

Let the function $$f(x)=x$$ be defined in the interval $$[0,1)$$.

The function $$f(x)=x$$ is a strictly increasing function, so the maximum is reached at the highest point of the interval.

But since it turns out that our interval is opened at the top part, we do not have a maximum value and, consequently, the absolute maximum does not exist.