Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

24/09/2023, 23:32 The Goat Problem

Home (/) / Blog (/blog/) / The Goat Problem

The Goat Problem


Posted by: christian (/blog/author/christian/) on 29 Dec 2022

(0 comments)

A goat is tethered on the perimeter of a circular paddock of grass by a rope of length r . What should r be to
allow the goat to graze on a maximum of half the area of the paddock?

This is a famous problem in recreational mathematics and is usually solved by approximate or numerical
methods, despite being relatively easy to express in the form of a mathematical equation (derived below). The
mathematician Ingo Ullisch recently derived an exact solution as the cosine of the ratio of two contour integrals
(https://doi.org/10.1007%2Fs00283-020-09966-0), which has been (generously) described as being in closed-
form:

∮ z/(sin z − z cos z − π/2) dz


1 |z−3π/8|=π/4
r = 2 cos( ).
2 ∮ 1/(sin z − z cos z − π/2) dz
|z−3π/8|=π/4

Here we will take the numerical solution approach. Let the paddock be a unit circle, with area π, centred at O,
and tether the goat at point T. The extent of the goat's grazing area is ilustrated below. Our job is to find the
value of r that makes this area equal to π/2 .

r 1

T θ α Q
1 O

First note a few relations that will prove useful:

https://scipython.com/blog/the-goat-problem/ 1/4
24/09/2023, 23:32 The Goat Problem

(1) α = π − 2θ

sin α
(2) sin θ =
r
2
(3) r = 1 + 1 − 2 cos α = 2(1 − cos α)

r
2
(4) 1 = 1 + r − 2r cos θ ⇒ θ = arccos( )
2

The second of these is the sine rule for triangles (https://en.wikipedia.org/wiki/Law_of_sines); the third and forth
follow from the cosine rule (https://en.wikipedia.org/wiki/Law_of_cosines).

The area of the circular sector TPQ is:

2
θ r θ
2
A1 = πr = ,
2π 2

the area of the circular sector OTP is:

α α
A2 = π =
2π 2

and the area of the triangle OTP is:

1 1
A3 = r sin θ = sin α,
2 2

using the result (2).

The area that the goat has to graze in is therefore A = 2(A1 + A2 − A3 ) and the problem is to solve

π
2
A = r θ + α − sin α =
2

for α and hence r . Using (1) to write θ =


1
(π − α) and rearranging yields:
2

π
sin α + (π − α) cos α = .
2

This equation is readily solved using, for example, the Newton–Raphson root-finding algorithm, as implemented
by scipy.optimize.newton (https://docs.scipy.org/doc/scipy/reference/generated/scipy.optimize.newton.html):

import numpy as np
from scipy.optimize import newton

def func(alpha):
return np.sin(alpha) + (np.pi - alpha) * np.cos(alpha) - np.pi / 2

theta_guess = np.pi / 2
alpha = newton(func, theta_guess)
print(alpha)

1.2358969242799094

This value for α is in radians. The corresponding rope-length, r is given, from (3) as:

r = np.sqrt(2 * (1-np.cos(alpha)))
print(r)

1.1587284730181215

https://scipython.com/blog/the-goat-problem/ 2/4
24/09/2023, 23:32 The Goat Problem

The variation of the grazable fraction of the paddock, A/π as a function of the rope length, r , can be plotted as
follows:

import matplotlib.pyplot as plt

rgrid = np.linspace(0, 2, 100)


cos_alpha = 1 - rgrid**2 / 2
alpha = np.arccos(cos_alpha)
theta = (np.pi - alpha) / 2
A = rgrid**2 * theta + alpha - np.sin(alpha)
r = 1.1587284730181215

plt.plot(rgrid, A / np.pi)
plt.hlines(0.5, 0, r, colors='k', linestyles='--')
plt.vlines(r, 0, 0.5, colors='k', linestyles='--')
plt.xlim(0, 2)
plt.ylim(0, 1)
plt.yticks([0, 0.5, 1])
plt.xlabel('$r$')
plt.ylabel('fractional grazing area')
plt.show()

Current rating: 5 1 2 3 4 5 Rate

Share on Twitter (http://twitter.com/home?status=https%3A//scipython.com/blog/the-goat-problem/%20The%20Goat%20Problem)

Share on Facebook (http://facebook.com/sharer.php?u=https://scipython.com/blog/the-goat-problem/&t=The%20Goat%20Problem)

← Maurer Roses (/blog/maurer-roses/)

https://scipython.com/blog/the-goat-problem/ 3/4
24/09/2023, 23:32 The Goat Problem

Modular arithmetic on a circle → (/blog/modular-arithmetic-on-a-circle/)

Comments
Comments are pre-moderated. Please be patient and your comment will appear soon.

There are currently no comments

New Comment
Name

required

Email

required (not published)

Website

optional

Comment

required

Comment

https://scipython.com/blog/the-goat-problem/ 4/4

You might also like