## Can I make RandomInstance use exact arithmetic?

3

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, 0},
EuclideanDistance["O", "TA"] == 4 Sqrt,
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. – m_goldberg – 2020-12-18T08:54:11.753

Actually, it isn't just "TA". All the points you specify are converted to machine precision. – m_goldberg – 2020-12-18T09:06:18.523

2I’m voting to close this question because the OP is asking for functionality that does not exist in the current version of Mathematica. – m_goldberg – 2020-12-18T09:08:04.977

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? – m_goldberg – 2020-12-18T09:31:09.873

"TA"/.RandomInstance[scene]["Points"]//RootApproximant gives {-2 Sqrt,-2 Sqrt}. – chyanog – 2020-12-18T10:03:38.967

@chyanog Thank you RootApproximant will do for now! But if somebody knows an internal switch that might make the RandomInstance work for exact numbers that would be lovely. I could see they may have done it to make the calculations run faster for the synthetic geometry system. – user13892 – 2020-12-18T13:54:44.847

2@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. – QuantumDot – 2020-12-19T20:00:23.780

@QuantumDot. Yes, it is a legitimate question for this site, but what the OP asks for is simply not possible, so why keep the question open? – m_goldberg – 2020-12-19T22:12:24.927

@m_goldberg because there may be undocumented solutions. In fact, a solution could be found by exploring GeneralUtilitiesPrintDefinitions[RandomInstance]. – QuantumDot – 2020-12-20T00:01:09.303

@QuantumDot. Then you should post an answer giving that solution. – m_goldberg – 2020-12-20T05:47:55.070

3

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, 0},
EuclideanDistance["O", "TA"] == 4 Sqrt,
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.

2

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

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