Digging an optimal trench

In order to solve this problem it will prove to be useful to have a function which takes as input a pair (x,y) and finds the x-coordinate of the point on the unit circle at which a tangent line can be drawn passing through the point (x,y). Actually, there are always two such lines so two functions will be needed.

To start, the following equation is obtained by taking an arbitrary point (x,y) and a point (p,q) on the unit circle such that the line connecting these two points is tangent to the unit circle. The slope of the tangent line at (p,q) is -p/q from simple trigonometry. Equating this to the slope of the line segment connecting the two points yields the equation.

> 1 - p**2 - y*sqrt(1 - p**2) = -p*(p - x);

Solving this equation for p will yield the x coordinate of the point at which the line passing through (x,y) is tangent to the unit circle. After some Maple manipulations this will become the function discussed above.

> solve(",p);

> allvalues(");


The two functions which yield the x-coordinate of the points at which the tangent to the unit circle passing through (x,y) can now be easily defined. They will be called XofTangent1 and XofTangent2.

> XofTangent1 := unapply("[1],(x,y));

> XofTangent2 := unapply(""[2],(x,y));

The equation has two solutions. This should be apparent from the geometry since the line passing from (x,y) tangent to the circle can pass on either side of the circle - hence the two solutions. Which solution is best for our purposes depends on the point (Q1,Q2). If it is in the upper right quadrant then the x-coordinate of the tangent line passing below the circle will be greater than that of the tangent line passing above the circle. In this case XofTangent1 will be used. If the point (Q1,Q2) falls in the lower right quadrant then XofTangent2 will be used.

Before continuing, the point Q1 and Q2 will be defined. These will be used to find points (P1U,P2U) and (P1L,P2L) which are the points at which the line tangent to the circle and passing through (Q1,Q2) touches the circle. The point (P1U,P2U) arises when (Q1,Q2) is the upper right quadrant while (P1L,P2L) arises when (Q1,Q2) is in the lower right quadrant.

> Q1 := cos(theta) + a/sqrt(1 + cot(theta)**2);

> Q2 := sin(theta) - a*cot(theta)/sqrt(1 + cot(theta)**2);

> P1U := XofTangent1(Q1,Q2);

> P1L := XofTangent2(Q1,Q2);

> P2U := -sqrt(1 - P1U**2);

> P2L := -sqrt( 1- P1L**2);

The next step is to find the point on the y axis at which the y-axis is intersected by the line tangent to the circle passing through (Q1,Q2). This point will be denoted by (0, z). It is easily found by calculating slopes and equating them. This will first be done only for the case when (Q1,Q2) is in the upper right quadrant and XofTangent1 is used.

> solve((Q2 - z)/Q1 = (P2U - Q2)/(P1U - Q1), z);

The length of the line segment is obtained by subtracting from z the height of the end of the line segment extending from the circular ditch.

> " - Q2;


The function denoted by LineSegment is now defined to be equal to the length just found.

> LineSegmentU := unapply(",(a,theta));

The total length of the ditch is now easily defined by adding to LineSegment the length of the circular ditch and the length of the two line segments attached to it. Call this function DitchLengthU to emphasize it is only valid when (Q1,Q2) is in the upper right quadrant.

> DitchLengthU := (a, theta) -> abs(LineSegmentU(a,theta)) + 2*a + (Pi - 2*theta);

The total ditch length in the case that (Q1,Q2) is in the lower right quadrant will now be considered. It is entirely analogous to the first case.


> solve((Q2 - z)/Q1 = (P2L - Q2)/(P1L - Q1), z);

> " - Q2;

> LineSegmentL := unapply(",(a,theta));

> DitchLengthL := (a, theta) -> abs(LineSegmentL(a,theta)) + 2*a + (Pi - 2*theta);

> plot3d(DitchLengthL(a,theta),a=0.4..1.7,theta=0.3..0.5,axes=boxed,numpoints=2000);

> plot(DitchLengthL(1,theta),theta=0.45...0.7,numpoints=150);

The length of the "U" shaped ditch mentioned in the problem statement has length Pi + 2. The value of this is found below.

> evalf(Pi + 2);

From the graphs considered, it is natural to look at the folllowing value of DitchLengthL:

> evalf(DitchLengthL(0.9,0.4));

Hence, digging a ditch with these parameters does even better than the "U" shaped ditch. The only thing which remains to be checked is that these parameters do indeed yield a dicth where (Q1,Q2) lies in the lower right quadrant. Recall that this simple means that Q2 is negative. Hence it suffices to substitue the parameters into this expression and see what happens.

> evalf(subs(a=0.9,theta=0.4,sin(theta) - a*cot(theta)/sqrt(1 + cot(theta)**2)));

The negative value confirms that this is a valid set of parameters.


Mike Zabrocki
Email address: zabrocki@yorku.ca
Department of Mathematics and Statistics
York University
Back to Department's Public Page
Back to my course Page
Back to top of page