The lake and pasture problem solved at last

The Full Problem, Finally Solved

Twelve years ago, in 2014, I was helping my girlfriend’s sister with her maths homework. The question was about a farmer with a fixed length of fence trying to enclose the largest possible area against a wall. It had the tidy A-level answer you’d expect, but it planted a question I couldn’t shake: what if the fence could be bent into a circular arc — and what if the wall were a circular lake?

I wrote up the in-between version first — an arc of fence against a straight wall, which turns out to be a semicircle — in “A farmer out standing in their field, their field was not mathematics”. Then I took on the lake itself in “The full problem”, carried the differentiation about as far as I could, and stalled on a transcendental equation I couldn’t solve. That post ends with the confession that the tools I needed were not yet in my mathematical toolbox.

They are now — though not, strictly speaking, mine. After twelve years I have finally solved it, with a great deal of help from Claude Opus 4.6. The working below is my own, but the factorisation that unblocks the whole thing is one I could never have found on my own. I actually finished this back in April, and it has taken me until now to write it up — which, given how long after Opus 4.6’s release that is, says rather more about my blogging schedule than about the model.

Circular Lake Geometry

Let the lake have radius \(R\) and centre \(C\).

We have a fixed length of fence \(L\) and both ends of it sit on the shore. For a fixed pair of end points the shape that encloses the most area is an arc of a circle, so let the fence be an arc of radius \(r\) with centre \(A\).

Label the rest of the picture:

  • \(B\) is one of the two points where the fence meets the shore.

  • \(D\) is the midpoint of the chord joining those two points. It lies on the line \(AC\).

  • \(E\) is where the line \(AC\) crosses the fence circle (inside the lake).

  • \(F\) is where the line \(AC\) crosses the lake circle (inside the fence circle).

Let \(\theta\) be the angle \(BAD\) and \(\phi\) be the angle \(BCD\).

As a reminder, a chord that subtends an angle \(\alpha\) at the centre of a circle of radius \(\rho\) has length

\[c = 2\rho \sin(\alpha/2)\]

and cuts off a segment of area

\[\frac{\rho^2}{2}(\alpha - \sin\alpha)\]

Our chord subtends \(2\theta\) at \(A\) and \(2\phi\) at \(C\).

The fence

The fence is the fence circle with the arc inside the lake removed, so:

\[L = 2r(\pi - \theta)\]

\[r = \frac{L}{2(\pi - \theta)}\]

The area

The area enclosed by the fence is the area of the circle of radius \(r\) minus the part of it the lake protrudes into.

The protruding bit is a lens, and the chord cuts it into two segments. The line \(AC\) cuts each of those in half, giving 4 pieces: the sector \(ABE\) minus the triangle \(ABD\) (we have that twice), and the sector \(CBF\) minus the triangle \(CBD\) (also twice).

The areas are symmetric in their formula but with different angles and radii.

\[BDE = P = \frac{r^2}{2}(\theta - \sin\theta\cos\theta)\]

\[BDF = Q = \frac{R^2}{2}(\phi - \sin\phi\cos\phi)\]

\[A = \pi r^2 - 2(P+Q)\]

We know that \(BD\) is common between the two triangles so:

\[R\sin\phi = r\sin\theta\]

Differentiating

To find the maximum area we need to differentiate.

\[\frac{dA}{d\theta} = \pi\frac{dr^2}{d\theta} - 2\left(\frac{dP}{d\theta} + \frac{dQ}{d\theta}\right) = 0\]

Let’s start with \(r\).

\[\frac{dr^2}{d\theta} = 2r\frac{dr}{d\theta}\]

\[\frac{dr}{d\theta} = \frac{L}{2}\cdot(-1)(\pi-\theta)^{-2}\cdot(-1) = \frac{L}{2(\pi - \theta)^2}\]

Spotting the \(r\) hiding in there:

\[\frac{dr}{d\theta} = \frac{r}{\pi - \theta}\]

Subbing back in:

\[\frac{dr^2}{d\theta} = \frac{2r^2}{\pi - \theta}\]

Then to tackle \(P\).

\[2P = r^2(\theta - \sin\theta\cos\theta)\]

\[2\frac{dP}{d\theta} = \frac{dr^2}{d\theta}(\theta - \sin\theta\cos\theta) + r^2(1 - \cos^2\theta + \sin^2\theta)\]

\[2\frac{dP}{d\theta} = \frac{2r^2(\theta - \sin\theta\cos\theta)}{\pi - \theta} + 2r^2\sin^2\theta\]

Let’s leave that in that form for now. On to \(Q\). The lake does not change size, so \(R\) is a constant and only \(\phi\) moves.

\[2Q = R^2(\phi - \sin\phi\cos\phi)\]

\[\frac{d(\sin\phi\cos\phi)}{d\phi} = \cos^2\phi - \sin^2\phi = 1 - 2\sin^2\phi\]

\[2\frac{dQ}{d\theta} = R^2\left(1 - (1 - 2\sin^2\phi)\right)\frac{d\phi}{d\theta} = 2R^2\sin^2\phi\,\frac{d\phi}{d\theta}\]

We can swap \(R\sin\phi\) for \(r\sin\theta\):

\[2\frac{dQ}{d\theta} = 2r^2\sin^2\theta\,\frac{d\phi}{d\theta}\]

Now we need \(\frac{d\phi}{d\theta}\), which comes from the common side.

\[R\sin\phi = r\sin\theta\]

\[\frac{d(R\sin\phi)}{d\phi}\frac{d\phi}{d\theta} = \frac{dr}{d\theta}\sin\theta + r\cos\theta\]

\[\frac{d(R\sin\phi)}{d\phi} = R\cos\phi\]

\[\frac{d\phi}{d\theta} = \frac{r}{R\cos\phi}\left(\frac{\sin\theta}{\pi - \theta} + \cos\theta\right)\]

Putting it together

\[\frac{dA}{d\theta} = \frac{2\pi r^2}{\pi - \theta} - \frac{2r^2(\theta - \sin\theta\cos\theta)}{\pi - \theta} - 2r^2\sin^2\theta - 2r^2\sin^2\theta\,\frac{d\phi}{d\theta}\]

The first two terms share a denominator, and \(\pi - \theta\) cancels nicely:

\[\frac{dA}{d\theta} = 2r^2\left(1 + \frac{\sin\theta\cos\theta}{\pi - \theta} - \sin^2\theta - \sin^2\theta\,\frac{d\phi}{d\theta}\right)\]

Using \(1 - \sin^2\theta = \cos^2\theta\) and pulling out a \(\cos\theta\):

\[\frac{dA}{d\theta} = 2r^2\left(\cos\theta\left(\cos\theta + \frac{\sin\theta}{\pi - \theta}\right) - \sin^2\theta\,\frac{d\phi}{d\theta}\right)\]

That bracket is exactly the one in \(\frac{d\phi}{d\theta}\), so the whole thing factorises:

\[\frac{dA}{d\theta} = 2r^2\left(\cos\theta + \frac{\sin\theta}{\pi - \theta}\right)\left(\cos\theta - \frac{r\sin^2\theta}{R\cos\phi}\right)\]

One more use of \(r\sin\theta = R\sin\phi\) tidies the second bracket. This is one of the factorisations I could never work out:

\[\cos\theta - \frac{\sin\theta\sin\phi}{\cos\phi} = \frac{\cos\theta\cos\phi - \sin\theta\sin\phi}{\cos\phi} = \frac{\cos(\theta + \phi)}{\cos\phi}\]

\[\frac{dA}{d\theta} = 2r^2\left(\cos\theta + \frac{\sin\theta}{\pi - \theta}\right)\frac{\cos(\theta + \phi)}{\cos\phi}\]

The maximum

The first bracket is never zero. Writing \(u = \pi - \theta\) it becomes \(\frac{\sin u - u\cos u}{u}\), which is positive for all \(0 < u < \pi\).

So the only way to get zero is

\[\cos(\theta + \phi) = 0\]

\[\theta + \phi = \frac{\pi}{2}\]

So that's the answer, a right angle!

The derivative is positive below this and negative above it, so it is a maximum.

The angles of the triangle \(ABC\) add to \(\pi\), so the angle at \(B\) is also \(\frac{\pi}{2}\). The two radii are perpendicular where the fence meets the shore, which means the fence meets the shore at a right angle. This is the same answer as fencing against a straight river, where the best shape is a semicircle.

To get actual numbers, \(\phi = \frac{\pi}{2} - \theta\) gives \(\sin\phi = \cos\theta\), so the common side becomes

\[R\cos\theta = r\sin\theta\]

\[\tan\theta = \frac{R}{r} = \frac{2R(\pi - \theta)}{L}\]

This has no closed form but it has exactly one solution in \(0 < \theta < \frac{\pi}{2}\) and is easy to solve numerically.

The maximum area

Expanding \(P\) and \(Q\):

\[A = r^2(\pi - \theta) + r^2\sin\theta\cos\theta + R^2\sin\phi\cos\phi - R^2\phi\]

The middle two terms are the triangles \(ABD\) and \(CBD\), twice each. Together they make the kite \(ABCB'\), and at the maximum that kite is two right-angled triangles with legs \(r\) and \(R\), so its area is just \(rR\). Using \(r(\pi - \theta) = \frac{L}{2}\) on the first term:

\[A_{max} = \frac{rL}{2} + rR - R^2\left(\frac{\pi}{2} - \theta\right)\]

Checks

As \(R \to \infty\) the shore becomes a straight line. Then \(\tan\theta \to \infty\) so \(\theta \to \frac{\pi}{2}\), \(r \to \frac{L}{\pi}\), and the last two terms cancel, leaving

\[A_{max} \to \frac{L^2}{2\pi}\]

which is the semicircle against a straight river.

For a worked example take a lake of radius \(R = 50\) m and \(L = 100\) m of fence. Then \(\tan\theta = \pi - \theta\), giving

\[\theta \approx 1.1128 \quad (63.8^\circ)\]

\[r \approx 24.65 \text{ m}\]

\[A_{max} \approx 1319.7 \text{ m}^2\]

The same fence against a straight shore would enclose \(1591.5\) m\(^2\). The lake bulging into the enclosure costs about 17% of the area.

Comments

Popular posts from this blog

Sortis - A paper empire game

Greedy meshing in javascript