Paul Calnan's Blog
Published December 21, 2020

I have been reading a Calculus book recently and came across formulas for min and max:

\[ \begin{align} min(x, y) = \frac{x + y - |y - x|}{2} \\ max(x, y) = \frac{x + y + |y - x|}{2} \end{align} \]

Here \(\frac{x + y}{2}\) is the average of the two numbers or the midpoint between the two on the number line.

Also \(\frac{|y - x|}{2}\) is half the distance between y and x. Adding it to the midpoint gives the maximum (rightmost) value and subtracting it from the midpoint gives the minimum (leftmost) value.

This is particularly interesting coming from a programming background where:

min(x, y) := x <= y ? x : y
max(x, y) := x >= y ? x : y

I never thought of coming up with a non-procedural formula for either of these.

We can prove that \(min(x, y) = \frac{x + y - |y - x|}{2}\) and \(max(x, y) = \frac{x + y + |y - x|}{2}\) as follows:

If \(x \leq y\), then \(|y - x| = y - x\). So \(x + y - |y - x| = x + y - y + x = 2x = 2 \cdot min(x, y)\), and \(x + y + |y - x| = x + y + y - x = 2y = 2 \cdot max(x, y)\).

In both cases, swap \(x\) and \(y\) to prove the formulas for \(x \geq y\).

Published December 21, 2020

Euler's formula states that for any real number \(x\):

\[ e^{ix} = \cos x + i \sin x \]

When \(x = \pi\), Euler's formula evaluates to:

\[ e^{i\pi} + 1 = 0 \]

This is known as Euler's identity and it links five fundamental mathematical constants (\(\pi\), \(e\), \(i\), \(0\), and \(1\)) in a beautifully simple equation. Richard Feynman called the equation "the most remarkable formula in mathematics."

The formula can be interpreted as saying that the function \(e^{i\phi}\) is a unit complex number, i.e. it traces out the unit circle in the complex plane as \(\phi\) ranges through the real numbers.

We can derive Euler's formula from the Maclaurin series expansions of \(\sin x\), \(\cos x\), and \(e^x\):

\[ \begin{align} \sin x &= \sum_{n=0}^\infty \frac{(-1)^n}{(2n+1)!} x^{2n+1} \\ &= x - \frac{x^3}{3!} + \frac{x^5}{5!} - \frac{x^7}{7!} + \cdots \\ \cos x &= \sum_{n=0}^\infty \frac{(-1)^n}{(2n)!} x^{2n} \\ &= 1 - \frac{x^2}{2!} + \frac{x^4}{4!} - \frac{x^6}{6!} + \cdots \\ e^x &= \sum_{n = 0}^{\infty} \frac{x^n}{n!} \\ &= 1 + x + \frac{x^2}{2!} + \frac{x^3}{3!} + \cdots \end{align} \]

Thus:

\[ \begin{align} e^{ix} &= \sum_{n = 0}^{\infty} \frac{(ix)^n}{n!} \\ e^{ix} &= 1 + ix + \frac{(ix)^2}{2!} + \frac{(ix)^3}{3!} + \frac{(ix)^4}{4!} + \frac{(ix)^5}{5!} + \frac{(ix)^6}{6!} + \frac{(ix)^7}{7!} + \cdots \\ &= 1 + ix - \frac{x^2}{2!} - \frac{ix^3}{3!} + \frac{x^4}{4!} + \frac{ix^5}{5!} - \frac{x^6}{6!} - \frac{ix^7}{7!} + \cdots \\ &= \left( 1 - \frac{x^2}{2!} + \frac{x^4}{4!} - \frac{x^6}{6!} - \cdots \right) + \left( ix - \frac{ix^3}{3!} + \frac{ix^5}{5!} - \frac{ix^7}{7!} + \cdots \right) \\ &= \left( 1 - \frac{x^2}{2!} + \frac{x^4}{4!} - \frac{x^6}{6!} - \cdots \right) + i\left( x - \frac{x^3}{3!} + \frac{x^5}{5!} - \frac{x^7}{7!} + \cdots \right) \\ &= \cos x + i\sin x \end{align} \]

This yields Euler's identity. Substitute \(\pi\) for \(x\). Since \(\cos \pi = -1\) and \(\sin \pi = 0\), it follows that:

\[ e^{i\pi} = -1 + 0i \]

or

\[ e^{i\pi} + 1 = 0 \]