2025-11-13 23:25:33
Here are four theorems that generalize the Pythagorean theorem. Follow the links for more details regarding each equation.
1. Theorem by Apollonius for general triangles.
2. Edsgar Dijkstra’s extension of the Pythagorean theorem for general triangles.
3. A generalization of the Pythagorean theorem to tetrahedra.
4. A unified Pythagorean theorem that covers spherical, plane, and hyperbolic geometry.
2025-11-12 22:55:40
The mth elementary symmetric polynomial of degree n
is the sum of all terms containing a product of m variables. So, for example,
These polynomials came up in the previous post. The problem was choosing weights to minimize the variance of a weighted sum of random variables can be solved using elementary symmetric polynomials.
To state the optimization problem more generally, suppose you want to minimize
where the ti and xi are positive and the ti sum to 1. You can use Lagrange multipliers to show that the solution is
2025-11-12 21:02:54
Suppose you have $100 to invest in two independent assets, A and B, and you want to minimize volatility. Suppose A is more volatile than B. Then putting all your money on A would be the worst thing to do, but putting all your money on B would not be the best thing to do.
The optimal allocation would be some mix of A and B, with more (but not all) going to B. We will formalize this problem and determine the optimal allocation, then generalize the problem to more assets.
Let X and Y be two independent random variables with finite variance and assume at least one of X and Y is not constant. We want to find t that minimizes
subject to the constraint 0 ≤ t ≤ 1. Because X and Y are independent,
Taking the derivative with respect to t and setting it to zero shows that
So the smaller the variance on Y, the less we allocate to X. If Y is constant, we allocate nothing to X and go all in on Y. If X and Y have equal variance, we allocate an equal amount to each. If X has twice the variance of Y, we allocate 1/3 to X and 2/3 to Y.
Now suppose we have n independent random variables Xi for i running from 1 to n, and at least one of the variables is not constant. Then we want to minimize
subject to the constraint
and all ti non-negative. We can solve this optimization problem with Lagrange multipliers and find that
for all 1 ≤ i, j ≤ n. These (n − 1) equations along with the constraint that all the ti sum to 1 give us a system of equations whose solution is
Incidentally, the denominator has a name: the (n − 1)st elementary symmetric polynomial in n variables. More on this in the next post.
2025-11-11 03:14:08
Excellent video by Almost Sure: What does Riemann Zeta have to do with Brownian Motion?
Connects several things that I’ve written about here including Brownian motion, the Riemann zeta function, and the Kolmogorov-Smirnov test.
The post Brownian motion and Riemann zeta first appeared on John D. Cook.2025-11-10 02:54:29
Suppose you have data on the closing prices of two stocks over 1,000 days and you want to look at the correlation between the two asset prices over time in rolling 30 day windows.

It seems that the rolling correlation is periodic. peaking about every 50 days.
But this is an artifact of the rolling window, not a feature of the data. I created the two simulated stock time series by creating random walks. The price of the stock each day is the price the previous day plus a sample from a normal random variable with mean zero and variance 1.

import numpy as np from scipy.stats import norm n = 1000 x = np.cumsum(norm.rvs(size=n)) y = np.cumsum(norm.rvs(size=n))
If you use a wider window, say 60 days, you’ll still see a periodic pattern in the rolling correlation, though with lower frequency.
2025-11-09 09:47:51
The area of a triangle can be computed directly from the lengths of its sides via Heron’s formula.
Here s is the semiperimeter, s = (a + b + c)/2.
Is there an analogous formula for spherical triangles? It’s not obvious there should be, but there is a formula by Simon Antoine Jean L’Huilier (1750–1840).
Here we denote area by S for surface area, rather than A because in the context of spherical trigonometry A usually denotes the angle opposite side a. The same convention applies in plane trigonometry, but the potential for confusion is greater in L’Huilier’s formula since the area appears inside a tangent function.
Now tan θ ≈ θ for small θ, and so L’Huilier’s formula reduces to Heron’s formula for small triangles.
Imagine the Earth as a sphere of radius 1 and take a spherical triangle with one vertex at the north pole and two vertices on the equator 90° longitude apart. Then a = b = c = π/2 and s = 3π/4. Such a triangle takes of 1/8 of the Earth’s surface area of 4π, so the area S is π/2. You can verify that L’Huilier’s formula gives the correct area.
It’s not a proof, but it’s a good sanity check that L’Huilier’s formula is correct for small triangles and for at least one big triangle.
The post Analog of Heron’s formula on a sphere first appeared on John D. Cook.