# Can I make RandomInstance use exact arithmetic?

When using RandomInstance on a GeometricScene the answer loses precision when root objects are encountered. Is there a way to make RandomInstance work with exact numbers?

For example consider the following:

scene =
GeometricScene[{"O","TA","IA","F"},
{
"O" == {0, 0},
"IA" == {4Sqrt[2], 0},
EuclideanDistance["O", "TA"] == 4 Sqrt[2],
PlanarAngle[{"IA", "O", "TA"}, "Counterclockwise"] == 240 °
}];


Grabbing the point "TA" produces an inexact result:

"TA" /. RandomInstance[scene]["Points"]


How can I make it get the exact answer?

• Sadly, no. It is a big weakness in the new synthetic geometry system. I reported it to Wolfram tech support awhile ago. In some cases, a reformulation of the problem can fix it so machine precision works. Commented Dec 18, 2020 at 8:54
• Actually, it isn't just "TA". All the points you specify are converted to machine precision. Commented Dec 18, 2020 at 9:06
• I’m voting to close this question because the OP is asking for functionality that does not exist in the current version of Mathematica. Commented Dec 18, 2020 at 9:08
• In your example, the calculations are accurate enough that Mathematica recognizes that IA and TA have the same length. Is that what you wanted from it? Commented Dec 18, 2020 at 9:31
• @m_goldberg This question does not need to be closed, nor should it. The OP's question squarely falls within the scope of this site. The question is Is it possible to make RandomInstance work with exact numbers? The answer is simply no. Commented Dec 19, 2020 at 20:00

Currently, all numeric quantities given in a GeometricScene expression are transformed to machine precision when RandomInstance is applied. This can be observed by evaluating the following code.

scene =
GeometricScene[{"O", "TA", "IA"},
{"O" == {0, 0},
"IA" == {4 Sqrt[2], 0},
EuclideanDistance["O", "TA"] == 4 Sqrt[2],
PlanarAngle[{"IA", "O", "TA"}, "Counterclockwise"] == 240 °}];
RandomInstance[scene] // InputForm


which produces

Notice that, although the 2nd argument (the hypotheses) preserve the exact quantities you entered, in the 1st argument all the symbolic points have been associated with machine precision quantities and these are the quantities that will be used by RandomInstance and FindGeometricConjectures when making calculations. So there is no way RandomInstance will use exact arithmetic.

However, as explained by chyanog in a comment to your question, sometimes it is possible to recover the exact values from the results returned.

Maybe you can. This seems to work, I guess, on the simple example:

RandomInstance[scene] /. x_Real :> RootApproximant[x] // InputForm
(*
GeometricScene[{{"IA" -> {4*Sqrt[2], 0},
"O" -> {0, 0}, "TA" -> {-2*Sqrt[2],
-2*Sqrt[6]}}, {}}, {"O" == {0, 0},
"IA" == {4*Sqrt[2], 0},
EuclideanDistance["O", "TA"] == 4*Sqrt[2],
PlanarAngle[{"IA", "O", "TA"},
"Counterclockwise"] == 240*Degree}, {}]
*)