What is the average area of the shadow cast by a cube, if we take the average over all possible orientations of the cube, while keeping its centre fixed?

This question was posed in a delightful video by Grant Sanderson, and answered for the case where the light source is infinitely far above the ground, so the shadow is cast by parallel rays. I won’t state the formula right now, so as not to spoil the fun if you decide to watch the video, or work out the answer for yourself. The derivation is a lot of fun, and you might find the result surprisingly simple.

On this page, we will find the average area of the shadow for the case where the light source is at a finite distance, but with the simplifying
feature that it will be located **directly above the centre of the cube**.

We will assume that:

- The cube has an edge length of 1.
- The cube’s centre is at a height
*h*above the ground. - The light source is at a distance δ directly above the centre of the cube, with δ > ½√3.

The quantity ½√3 here is the distance from the centre
of the cube to one of its vertices, so the condition on δ will ensure that, however the cube is oriented,
the light source is always **outside the cube**. We could impose a similar condition on *h*, so that no portion
of the cube is ever below the ground, but although that would be necessary for the problem to make sense *physically*, all the geometry
of rays from the light source intersecting the ground continues to work for any value of *h*.

What does it mean to take an average over all possible orientations of the cube? One way to formalise this is to
suppose that we start with the cube in a certain orientation, then average over the result of applying all possible
rotations. The group of all rotations in three dimensions, known as SO(3), can be given a coordinate system and
a **measure**, which is essentially a probability distribution, assigning to each subset of the space a number such that
the whole space has a measure of 1. What’s more, there is a unique way of doing this, such that
the measure of a set of rotations is unchanged if we multiply them all by any other fixed rotation.
In general, this is known as the Haar measure
of the group. If, instead of the rotations themselves, we work with unit quaternions, the space we are considering will be the 3-dimensional surface of a hypersphere in four dimensions,
and the Haar measure is the usual geometric measure of volume that the surface inherits from 4-dimensional Euclidean space.

If all of that sounds a bit abstract, don’t worry, because the consequences of formalising things this way are precisely what
you would expect, intuitively. Any vector in our initial orientation of the cube (say, a vector ** n** normal to one of the faces) ends up with
equal probability of pointing in any direction, so we can average it over the 2-dimensional surface of an ordinary sphere in three dimensions.
And any vector

We will proceed by computing the average area of the quadrilateral shadow cast on the ground by **a single face of the cube**, as
the cube itself is swept through all possible orientations while its centre is kept fixed.
The shadow of the whole cube is a more complicated polygon, but its area at any instant will be equal to **half** the sum of
the areas of the shadows of all six faces, because each geometric ray casting the shadow will enter the cube on one face and leave it
on another. Since all six faces must, by symmetry, have the same average area, the average area
of the cube’s shadow will be exactly **three times** the average area of a single face’s shadow.

Suppose the outward-pointing normal vector to the face is:

= (sin θ cos φ, sin θ sin φ, cos θ)n

where θ measures the angle from the vertical, and ranges from 0 to π, while φ is a longitudinal angle ranging from 0 to 2π. If we integrate over these variables, we need to weight the quantity we are averaging by sin θ, the radius of a circle on the unit sphere at an angle of θ from the north pole, and then divide the integral by 4π, the total area of the unit sphere.

Given that direction for the face normal ** n**, we will suppose that the two directions of the face edges are:

e_{1}= (–sin α cos θ cos φ – cos α sin φ, cos α cos φ – sin α cos θ sin φ, sin α sin θ)

e_{2}= (–cos α cos θ cos φ + sin α sin φ, –sin α cos φ – cos α cos θ sin φ, cos α sin θ)

These are unit vectors that are orthogonal to each other, and both are orthogonal to ** n**,
with α specifying the amount of rotation in the plane orthogonal to

The four vertices of the face are then given by:

= (0,0,vh) + ½± ½ne_{1}± ½e_{2}

We project these vertices with rays from the light source, at ** s** = (0,0,

P(x,y,z) = [(h+δ) / (h+δ–z)] (x,y)

The area of any triangle in two dimensions can be found as half the determinant of the 2×2 matrix whose columns are two edge vectors
of the triangle (the angle moving counterclockwise from the first edge to the second must pass through the interior of the triangle to yield the
correct sign). The area of any triangle in **three** dimensions can be found as half the magnitude of the cross product of any two edges.
Combining these with our projection formula, with a bit of algebra it is not too hard to show that the factor by which the area of a triangle
is multiplied to give the area of its shadow is:

Triangle shadow area factor = ½(h+δ)^{2}(· (n–t)) / [(sz_{1}–h– δ) (z_{2}–h– δ) (z_{3}–h– δ)]

Here *z*_{i} are the *z* coordinates of the triangle’s vertices,
** n** is a unit vector normal to the plane of the triangle,

If we divide our square face into two triangles with equal area of ½, the area of the shadow of the face will just be the average of these factors for the two triangles. If we grind through all the calculations, we end up with:

A(θ, α) = | 4 (h+ δ)^{2}(2δ – cos θ) (2δ cos θ – 1) / ((2δ – cos θ)^{4}– 2 (2δ – cos θ)^{2}sin^{2}θ + (cos^{2}α – sin^{2}α)^{2}sin^{4}θ) |

Note that the angle φ does not appear here at all! Because we have chosen to place the light source directly above the centre of the cube, the longitudinal angle makes no difference to the size of the shadow. As a further check that this formula makes sense, we can put θ=0, which gives:

A= 4 (h+ δ)^{2}/ (2δ – 1)^{2}

Putting *z*=*h*+½ in the projection formula gives a linear scaling factor whose square matches this.

We will perform the integration over α first. Because α measures the rotation of the
face **in its own plane**, the value of α cannot have any effect on the sign of the quantity we are using to compute the area.
So we can integrate over the full range of α without worrying about having to take
the opposite value of the integrand for part of the range (as we will need to do for θ).

We will make use of the formula:

1/(2π) ∫_{0}^{2π}1 / (b+ (cos^{2}α – sin^{2}α)^{2}) dα = 1 / √[b(b+1)]

This can be proved fairly easily by means of Cauchy’s residue theorem, after converting the denominator of the integrand into:

b+ (cos^{2}α – sin^{2}α)^{2}= ½(1 + 2b+ cos 4α)

This expression has four distinct zeroes with real parts between 0 and 2π in the upper half-plane of the complex numbers. By deforming the integral from 0 to 2π to loop around these four zeroes, the residues of the original function can be added up to give the result we are claiming.

This lets us average the area over α, obtaining:

A(θ) = | 4 (h+ δ)^{2}(2 δ cos θ – 1) / [(2 cos^{2}θ – 4 δ cos θ + 4 δ^{2}– 1) √(3 cos^{2}θ – 4 δ cos θ + 4 δ^{2}– 2)] |

The sign of the quantity whose absolute value we are taking depends entirely on the (2δ cos θ – 1) term in the numerator. Neither of the expressions in the denominator have real zeroes for θ, given the restriction we have imposed on δ. So we can integrate the expression and its opposite over the two ranges for θ where the sign is constant, on either side of arccos(1/(2δ)).

When we integrate over θ, we need to multiply the expression above by sin θ to get the correct measure on the sphere of directions, and then divide by 2. Why 2, and not the area of the sphere, 4π? Because there is no dependence on φ, we aren’t going to bother explicitly integrating for φ from 0 to 2π, but if we did, that would introduce a factor of 2π, and then dividing by 4π would simply be the same as dividing by 2.

This integral can be performed after making the substitution *u* = cos θ. The indefinite integral can then be expressed as:

I(u) = (h+ δ)^{2}arctan( ( (u– 2 δ) √(3u^{2}– 4 δu+ 4 δ^{2}– 2)) / (u^{2}– 1) )

Or, in a form you can cut and paste into software like Mathematica, if you want to verify the derivative:

(d + h)^2*ArcTan[((-2*d + u)*Sqrt[-2 + 4*d^2 - 4*d*u + 3*u^2])/(-1 + u^2)]

Then the sum of the two definite integrals, with the appropriate signs, multiplied by half the number of faces, yields a final result:

Average unit cube shadow = 3 (h+ δ)^{2}arctan( (√(3 – 16 δ^{2}+ 16 δ^{4})) / (1 – 8 δ^{2}+ 8 δ^{4}) )

Some care is needed taking the arctan here; when the denominator crosses zero so the argument becomes negative, we need to choose the value of the angle that lies in the second quadrant (i.e. between π/2 and π) rather than using negative values.

- In the limit of δ → ∞,
the arctan term tends to 1/(2δ
^{2}), so the average area approaches 3/2, the same value as for the orthogonal projection from an infinitely distant light source. - For δ=1, the arctan term becomes π/3, so the average area is simply (
*h*+1)^{2}π. - As δ → ½√3, the value at which a corner of the cube makes contact with the light source, the arctan term goes to π, so the
**average**area approaches the finite limit 3 (*h*+½√3)^{2}π rather than going to infinity.

These features are illustrated in the plot below. The numerical values here correspond to setting *h*=1.

The average shadow area for a cube with any edge length can be found by rescaling the unit cube version:

Average cube shadow, edge lengthL= 3 (h+ δ)^{2}arctan(L^{2}(√(3L^{4}– 16 δ^{2}L^{2}+ 16 δ^{4})) / (L^{4}– 8 δ^{2}L^{2}+ 8 δ^{4}) )

We could generalise these calculations to any convex polyhedron at all, but to keep the results simple we will impose the restriction that all the faces are regular polygons, with the line from the centre of the face to the centre of the polyhedron perpendicular to the plane of the face. That includes the Platonic solids, whose faces are identical regular polygons, but we won’t need to assume that all the faces are the same, as different sets of faces can always be averaged separately then added together.

Consider a face that is a regular *m*-gon of radius *r* (that is, each vertex is a distance *r* from the centre of the face),
and the centre of the face lies at a perpendicular distance *p* from the centre of the polyhedron.
As before, we will assume that the centre of the polyhedron is at (0,0,*h*), while the light source is at ** s** = (0,0,

The simplest approach will be to decompose the *m*-gon into *m* isosceles triangles, each with one vertex at the centre of the face and two
that are adjacent vertices of the face itself. We will make use of three mutually orthogonal vectors:

= (sin θ, 0, cos θ)n

e_{1}= (–sin α cos θ, cos α, sin α sin θ)

e_{2}= (–cos α cos θ, –sin α, cos α sin θ)

which are essentially the same as those we employed in the previous section, but now with hindsight we have set the angle φ in the original vectors to zero, because we know that the value of φ will make no difference to the area of the shadow.

Our triangle’s vertices will be:

v_{1}= (0,0,h) +pn

v_{2,3}= (0,0,h) +p+nr(cos π/me_{1}± sin π/me_{2})

The area of the shadow is then:

T(θ, α) = |[r^{2}(h+ δ)^{2}(p– δ cos(θ)) sin(2π/m)] / [2 (δ –pcos(θ)) (δ –pcos(θ) +rsin(π/m– α) sin(θ)) (δ –pcos(θ) –rsin(π/m+ α) sin(θ))] |

This can be averaged over α fairly easily by again using Cauchy’s residue theorem, though the integrand takes a slightly different form. The general result we rely on is:

1/(2π) ∫_{0}^{2π}1 / [(a+ sin(b– α))(a– sin(b+ α))] dα = 2a/ [(2a^{2}– cos(2b) – 1) √(a^{2}– 1)]

This gives us:

T(θ) = | [r^{2}(h+ δ)^{2}(p– δ cos(θ)) sin(2π/m)] / [ ((2p^{2}+r^{2}(1 + cos(2π/m))) cos(θ)^{2}– 4pδ cos(θ) + 2 δ^{2}–r^{2}(1 + cos(2π/m))) √((p^{2}+r^{2}) cos(θ)^{2}– 2pδ cos(θ) –r^{2}+ δ^{2}) ] |

As before, the integral that averages over θ can be performed after making the substitution *u* = cos θ and dividing by 2. The indefinite integral is:

I(u) = ¼ (h+ δ)^{2}arctan([2 sin(2π/m) (pu– δ) √(r^{2}(u^{2}– 1) + (pu– δ)^{2})] / [r^{2}(u^{2}– 1) + (r^{2}(u^{2}– 1) + 2 (pu– δ)^{2}) cos(2π/m)])

Or in machine-friendly form:

((d + h)^2*ArcTan[(2*(-d + p*u)*Sqrt[(-d + p*u)^2 + r^2*(-1 + u^2)]*Sin[(2*Pi)/m])/ (r^2*(-1 + u^2) + (2*(-d + p*u)^2 + r^2*(-1 + u^2))*Cos[(2*Pi)/m])])/4

Although this expression certainly has the correct derivative, the arctan function is multivalued (because tan is periodic), and we
risk having discontinuities in the value between the endpoints of our region of integration, introducing extra multiples of π that don’t matter
in an indefinite integral (because the derivative of any added constant is zero), but can reck the result of our definite integrals.
So, for the next step we will consider the arctan to have been rewritten as a function of separate *x* and *y* arguments, rather
than just the ratio *y*/*x*. Since there are different conventions as to the order in which the two arguments should be given,
we will label them explicitly:

I(u) = ¼ (h+ δ)^{2}arctan(y= 2 sin(2π/m) (pu– δ) √(r^{2}(u^{2}– 1) + (pu– δ)^{2}),x=r^{2}(u^{2}– 1) + (r^{2}(u^{2}– 1) + 2 (pu– δ)^{2}) cos(2π/m))

The integrand changes sign at *u* = *p*/δ, and the sum of the two definite integrals, multiplied by *m*, then gives us:

Averagem-gon shadow area = (h+ δ)^{2}((m/2) arctan(y= 2 sin(2π/m) √((p^{2}– δ^{2}) (p^{2}+r^{2}– δ^{2})),x= –r^{2}– (2p^{2}+r^{2}– 2 δ^{2}) cos(2π/m)) – π)

The average shadow area for the entire polyhedron would then be **half the sum of this for all faces**.

As a cross-check, for the unit cube we have:

m= 4

p= ½

r= 1/√2

Average square face shadow area = (h+ δ)^{2}(2 arctan(y= 2 √((¼ – δ^{2}) (¾ – δ^{2})),x= –½) – π)

It is not immediately obvious that this answer agrees with our previous calculation, but using the formula for the tan of a double angle, they can be shown to be the same.

To compare the behaviour of the shadow size between polyhedra, we need to make some choices that put the different shapes on an equal footing. If we scale all the Platonic solids to fit into a sphere of radius 1, with its centre at a height of 1, and divide the average shadow areas by the surface areas of the polyhedra, we obtain the following curves:

So the ratio for large values of δ is very similar (and all of these will tend to a limit of ¼), while the shadow size when the light source is close is influenced by the solid angle that the body of the polyhedron subtends at a vertex, which is much more for a dodecahedron that it is for a tetrahedron. The ratio for a sphere is shown for comparison; this tend to infinity as the light source approaches the surface of the sphere.