<-- back

Math.min() > Math.max()


Why Math.min() > Math.max() is true ?

console.log( Math.min() ); // Infinity
console.log( Math.max() ); // -Infinity

Writing Math.min() as well as Math.max() without arguments, is like looking for the lower and upper bound of an empty set.

So we should have something that looks like this:

Let 𝐸 = ∅, inf(𝐸) > sup(𝐸)

So it makes sense to write Infinity > -Infinity

But why?

To begin with, we have:

(A)
For any nonempty set of real numbers 𝐸 with an upper bound in ℝ, there exists a smaller upper bound. We call this sup(𝐸). For any nonempty set of real numbers 𝐸 having a lower bound in ℝ, there exists a larger lower bound. We call this inf(𝐸).

Right.

Now, suppose we have any set 𝐸 ⊆ 𝑅. We define 𝑈(𝐸):= {𝑥 ∈ ℝ : ∀ 𝑦 ∈ 𝐸 (𝑦 ≤ 𝑥)} as the set of upper bounds of 𝐸 in ℝ.

Similarly,
let 𝐿(𝐸) := {𝑥 ∈ ℝ : ∀ 𝑦 ∈ 𝐸 (𝑥 ≤ 𝑦)} be the set of lower bounds of 𝐸.

We can then show that:
𝑈(𝐸) is an upwardly closed set, i.e. if 𝑥 ∈ 𝑈(𝐸) and 𝑧 ∈ ℝ with 𝑥 ≤ 𝑧, then 𝑧 ∈ 𝑈(𝐸).

Similarly, 𝐿(𝐸) is downwardly closed.

The only upwardly closed subsets of ℝ are ∅, ℝ, and sets of the form (𝑎, →) := {𝑥 ∈ ℝ : 𝑎 < 𝑥} and [𝑎, →) := {𝑥 ∈ ℝ : 𝑎 ≤ 𝑥} for 𝑎 ∈ ℝ.

Similarly, the closed subsets down of ℝ are ∅, ℝ, and the sets (←, 𝑏) := {𝑥 ∈ ℝ : 𝑥 < 𝑏} and (←, 𝑏] := {𝑥 ∈ ℝ : 𝑥 ≤ 𝑏}.

- ℝ is the only upwardly closed subset of the reals that is unbounded below.
- ℝ is the only subset of the downward closed reals that is unbounded above.
- 𝐸 = ∅ if and only if 𝑈(𝐸) = 𝐿(𝐸) = ℝ.

Perfect!

Now let's rephrase (A) more concisely:

(A rephrased)
For any nonempty set of real numbers 𝐸, either 𝑈(𝐸) is empty, which meansthat 𝐸 has no upper bound in ℝ.
Let 𝑈(𝐸) have a least element, which means that 𝑈(𝐸) = [𝑎, →) for some 𝑎 ∈ ℝ.
This 𝑎 is uniquely determined by 𝐸, and we call it sup(𝐸).
Similarly, for any nonempty set of real numbers 𝐸, either 𝐿(𝐸) is empty,or 𝐿(𝐸) = (←, 𝑏] for some unique 𝑏 ∈ ℝ, which we call inf(𝐸).
In the case where 𝐸 = ∅, we have 𝑈(𝐸) = ℝ, which has no least element, so we cannot say that there exists a real number that we call sup(𝐸) in this case.
Consequently, "sup(𝐸) = -∞" must be interpreted to mean that 𝑈(𝐸) is unbounded below, which is just another way of saying that 𝐸 is empty.
Similarly, "inf(𝐸) = +∞" means that 𝐿(𝐸) is unbounded above, which is another way of saying that 𝐸 is empty.
Finally, we note that if 𝐸 is nonempty and bounded above, then sup(𝐸) = inf(𝑈(𝐸)).

In this view, one should interpret "sup(𝐸) = +∞" in the same way as "inf(𝑈(𝐸)) = +∞", i.e., 𝑈(𝐸) is empty. This means that 𝐸 is unbounded above. Similarly, one should interpret "inf(𝐸) = -∞" to mean that 𝐸 is unbounded below.

These conventions are generally easier to understand than "sup(𝐸) = -∞" and "inf(𝐸) = +∞" both mean "𝐸 = ∅".

Bottom line, console.log( Math.min() > Math.max() ); is "true", and now it won't look weird to you.