How capable is Mathematica when it comes to typical school geometry problems? Is there a way to throw constraints at it and get it to spit out a solution? Here are two geometry problems from my graduation exam that are simple to solve by hand, but all my attempts to make Mathematica do it have failed. Mind you, I'm by no means proficient in Mathematica, let alone its geometry features.

Problem 1:

enter image description here

I'm omitting what's obvious from the drawing for brevity. If the radius of the small circle is 15 cm, what is the radius of the large circle? The solution is 32,32 cm.

Problem 2:

enter image description here

A train travels from A to B and a car travels from B to C, both at constant speed. They start moving at the same time. The car is twice as fast as the train. The rail from A to B is 53 km long. How much kilometers will the train have traveled when the flight distance between the train and the car is minimal? The solution is 15,143.

If these problems cannot be solved for whatever reason, can you give me example of a similar one that can?


I might have phrased my question poorly, leading to a lot of confusion. I wanted to see a problem solved with minimal pre-solving by the human. Ideally, only the constraints explicitly stated in the problem text and those obvious from the image should constitute the input. Take the second problem as an example. I want to tell Mathematica the following things:

  • There is a point X on AB (representing the train)
  • There is a point Y on BC (the car)
  • |AB| = 53km
  • 2 * |AX| = |BY|
  • The angle between BA and BC (as vectors) is 60 degrees.
  • What is the value of |AX| when |XY| is minimal?

There are ways to express these thing in Mathematica, like X ∈ Line[A, B] where A, B and X would remain elsewhere defined as points with symbolic coordinates. These coordinates shouldn't be explicitly stated, as m_goldberg did in his solution. He choose them, quite cleverly, so that the expression of the problem was the shortest. This takes insight into the problem, which shouldn't be necessary since the coordinates can remain arbitrary, that is, Mathematica should be able to cancel them out, in a way. If you were to solve this problem by hand, you wouldn't do it analytically, the coordinates would remain undefined.

It is obvious to me that once you express these problems in a suitable way, Mathematica can solve them. In some sense, it's only acting as a glorified calculator. If you simplify them to the bare arithmetic, a simple handheld four-function calculator could solve them, but that doesn't mean it's actually solving geometry. In fact both m_goldberg's solutions have little mention of geometry, even though Mathematica does provide facilities to talk about geometry (Triangle, Line, and so on).

The somber conclusion is that, even for problems as simple as my examples, the constraints are too wast for a computer to crunch trough without human aid. Or perhaps Mathematica doesn't implement the required methods, which surprises me since it boasts it's symbolic capabilities.

  • 1
    $\begingroup$ One can certainly program Mathematica to compute the result if one knows how to solve the problem. Is that what you want? (If you want M to figure out how to solve the problem, you still would have to figure out how to specify the problem as a computation of some sort.) $\endgroup$
    – Michael E2
    Jun 28 '16 at 22:47
  • 3
    $\begingroup$ Mathematica is by far the world's best computer system for symbolic manipulation and calculation and it can trivially handle any problem from high-school mathematics. But part of solving mathematics problems is casting a problem into mathematical form (as is obvious in your Problem 2), and this requires the human. $\endgroup$ Jun 28 '16 at 23:04
  • 1
    $\begingroup$ Here's a diagram for your first problem, from which the answer should now be easy to derive: Graphics[{Disk[#, 15] & /@ CirclePoints[10 Sqrt[3], 3]}]. $\endgroup$
    – J. M.'s torpor
    Jun 28 '16 at 23:26
  • $\begingroup$ The point of all of this, I guess, is that you will need to formulate your problems in the analytic geometry framework before you can use Mathematica, since the software works with coordinates. $\endgroup$
    – J. M.'s torpor
    Jun 29 '16 at 3:34
  • 1
    $\begingroup$ The lamebrainest piece of software I have ever used is Geogebra. You pull down geometric shapes from menus, place, deform, get a few tangents and voila, you have a 15 digit approximation for the answer. You do a PSLQ and like magic you have an exact symbolic answer all without knowing anything about Euclidean geometry or even when you were born. My answer solves the problem exactly as I would solve it with Geogebra using Mma. The only difference is that Mma gets the exact answers right from the beginning. I have 0 knowledge of any geometry and am a noob at Mma, how can you beat that? $\endgroup$
    – bobbym
    Feb 7 '17 at 15:15

For your 1st problem, assume the following.

  • r is radius of small circles.
  • s is the distance between the center of the large circle and the center of any of small circles.
  • R is the radius of large circle.

r == 15 is given; r == s Sin[60 °] and R == r + s by inspection, so

With[{r = 15},
  Solve[Eliminate[{r == s Sin[60 °], R == r + s}, s], R]][[1,1]]

R -> 5 Sqrt[3] (2 + Sqrt[3])

% // N

R -> 32.3205

For your 2nd problem. Let s be the distance the train has traveled.

Minimize[EuclideanDistance[{53 - s, 0}, 2 s {Cos[60 °], Sin[60 °]}], s]

{53 Sqrt[3/7], {s -> 106/7}}

% // N

{34.6966, {s -> 15.1429}}

Note: The problem doesn't change if your diagram is flipped as follows

Module[{A = {53, 0}, B = {0, 0}, C = 2 53 {Cos[60 °], Sin[60 °]}},
  {Line[{B, A}], Line[{B, C}],
   Text["A", A + {2, 0}], Text["B", B + {-2, 0}], Text["C", C + {1, 1}]}]]


and this orientation of the three points is more convenient to work with, so it is what I used to formulate my Mathematica solution.

  • $\begingroup$ The formerly documented Solve[{r == s Sin[60 \[Degree]], R == r + s}, R, {s}], discussed here, also eliminates s while solving for R. $\endgroup$
    – Michael E2
    Jun 29 '16 at 14:49
  • $\begingroup$ Your solutions are elegant and I thank you, but they sadly weren't what I was seeking. Could you please look at the edit in my OP? $\endgroup$
    – user28189
    Jun 29 '16 at 19:17

This is just to illustrate for the first problem (calculation and visualization).

Module[{tg = SSSTriangle[30, 30, 30], c, ans},
 c = RegionCentroid[tg];
 ans = EuclideanDistance[c, tg[[1, 1]]] + 15;
 Graphics[{Circle[c, ans], LightGray, Disk[#, 15] & /@ tg[[1]], Red, 
   PointSize[0.02], Point[tg[[1]]], EdgeForm[Black], FaceForm[None], 
   Polygon[tg[[1]]], Line[{c, #}] & /@ tg[[1]], Blue, Point[c],
   Purple, Arrowheads[{-0.05, 0.05}],
   Arrow[{c, c + ans Normalize[c - tg[[1, 1]]]}], 
   Text[Framed[ans, Background -> White], 
    c + ans Normalize[c - tg[[1, 1]]]/2]}]]

enter image description here


ubpdqn beat me to it and his looks better.

You can have no knowledge about the problem at all and still get Mma to get the answer, just use it like Geogebra on steroids.

t = SSSTriangle[30, 30, 30];
cent = RegionCentroid[t];
Maximize[y, {x, y} \[Element] Circle[cent, 15]];
big = Circle[cent, 15 + 15 Sqrt[3] - 5 Sqrt[3]];
Graphics[{t, Circle[{0, 0}, 15], Circle[{30, 0}, 15], 
Circle[{15, 15 Sqrt[3]}, 15], big}]

15 + 15 Sqrt[3] - 5 Sqrt[3] // N

Not the answer you're looking for? Browse other questions tagged or ask your own question.