# How to resolve this calculation prompt that appears after running the drawing program?A bug in version 14.1.0 [duplicate]

The code as following and the code runs in Mathematica version 14.1.0.

Clear["*"];
Manipulate[
Module[{circle, center, radius, pointP, pointB, tangentPoint},
circle = Disk[{0, 4}, 1]; center = {0, 4}; radius = 1;
pointP = {a^2/4, a}; pointB = {-1, a};
tangentPoint =
NSolve[EuclideanDistance[{x, y}, center] == radius &&
EuclideanDistance[{x, y}, pointP] ==
Sqrt[radius^2 + EuclideanDistance[pointP, center]^2], {x, y},
Reals];
tangentPoint = {x, y} /. tangentPoint;
Show[ContourPlot[{y^2 == 4 x, x^2 + (y - 4)^2 == 1,
x == -1}, {x, -3, 6}, {y, -8, 8},
ContourStyle -> {Blue, Thick, Dashed, Black},
PerformanceGoal -> "Quality", Frame -> False, Axes -> True,
AxesOrigin -> {0, 0}, AxesLabel -> {"x", "y"},
AspectRatio -> Automatic],
Graphics[{Red, PointSize[0.02], Point[pointP],
Text[Style["P", 12, Italic, FontFamily -> "Times"],
pointP, {-1, -1}], Black, PointSize[0.02], Point[pointB],
Text[Style["B", 12, Italic, FontFamily -> "Times"],
pointB, {1, 0}], Black, Dashed, Line[{pointP, pointB}], Black,
PointSize[0.02], Point[center],
Text[Style["A", 12, Italic, FontFamily -> "Times"],
center, {1, 0}], Black, Line[{pointP, #}] & /@ tangentPoint}],
PlotRange -> {{-3, 6}, {-8, 8}}]], {a, 0, 6}]


After running the code, the image appears normal when stationary, but when I click the button to make the moving point P start moving, an error message is displayed.

NSolve::ratnz: NSolve was unable to solve the system with inexact coefficients. The \
answer was obtained by solving a corresponding exact system and \
numericizing the result.


After adding Rationalize, why is the problem still there when I run the code in version 14.1.0?

• (-1) for never searching before asking. Commented Sep 5 at 0:36
• i.sstatic.net/DaQO3tu4.png Clearly you've modified Daniel's code in some way, but you've only showed us an incomplete screenshot. Sadly I cannot downvote twice. Commented Sep 5 at 1:00
• 1. Can't reproduce in version 14.1: wolframcloud.com/obj/491fbe13-604f-4e93-8d08-15cbfc4f5cd4 2. You should always mention your Mathematica version. 3. I don't see In[] symbol in the screenshot, have you really executed the code? Commented Sep 5 at 5:17

Nothing to worry about, this is only a warning. But the error message is cumbersome. To get rid of it, rationalize pointP and pointB:

Clear["*"];
Manipulate[
Module[{circle, center, radius, pointP, pointB, tangentPoint},
circle = Disk[{0, 4}, 1]; center = {0, 4}; radius = 1;
pointP = {a^2/4, a} // Rationalize;
pointB = {-1, a} // Rationalize;
tangentPoint =
NSolve[EuclideanDistance[{x, y}, center] == radius &&
EuclideanDistance[{x, y}, pointP] ==
Sqrt[radius^2 + EuclideanDistance[pointP, center]^2], {x, y},
Reals];
tangentPoint = {x, y} /. tangentPoint;
Show[ContourPlot[{y^2 == 4 x, x^2 + (y - 4)^2 == 1,
x == -1}, {x, -3, 6}, {y, -8, 8},
ContourStyle -> {Blue, Thick, Dashed, Black},
PerformanceGoal -> "Quality", Frame -> False, Axes -> True,
AxesOrigin -> {0, 0}, AxesLabel -> {"x", "y"},
AspectRatio -> Automatic],
Graphics[{Red, PointSize[0.02], Point[pointP],
Text[Style["P", 12, Italic, FontFamily -> "Times"],
pointP, {-1, -1}], Black, PointSize[0.02], Point[pointB],
Text[Style["B", 12, Italic, FontFamily -> "Times"],
pointB, {1, 0}], Black, Dashed, Line[{pointP, pointB}], Black,
PointSize[0.02], Point[center],
Text[Style["A", 12, Italic, FontFamily -> "Times"],
center, {1, 0}], Black, Line[{pointP, #}] & /@ tangentPoint}],
PlotRange -> {{-3, 6}, {-8, 8}}]], {a, 0, 6}]


• After adding it, why is the problem still there when I run the code? Commented Sep 5 at 0:39
• I have version 14.1 and this code runs without problems. Commented Sep 5 at 7:00
• With version 14.1, I find that the problem still exists for the code in this answer. Commented Sep 6 at 9:20
• Strange, I tried it again and it runs without problems. Commented Sep 6 at 9:50
• I agree that this is strange. Did you test your code by copying it from your answer above? Also, on what operating system did you run the code? @xzczd suggests in a comment that different operating systems may affect when this warning message occurs. Commented Sep 6 at 14:53

Because EuclideanDistance and Sqrt themselves produce numbers that are not rationalized, it sometimes is necessary to Rationalize their output to eliminate the warning message. Specifically, modify the NSolve call in the question to

NSolve[Rationalize[EuclideanDistance[{x, y}, center] - radius, 0] == 0
&& Rationalize[EuclideanDistance[{x, y}, pointP] -
Sqrt[radius^2 + EuclideanDistance[pointP, center]^2], 0] == 0,
{x, y}, Reals];


I have tested this result with version 14.1.0 for Microsoft Windows (64-bit) (July 16, 2024).

• Wait, do you mean that in 14.1 windows, EuclideanDistance gives inexact output e.g. EuclideanDistance[{1, 2, 3}, {2, 4, 6}] gives 3.74166? This isn't the behavior of Linux version: i.sstatic.net/GNSinWQE.png Commented Sep 6 at 12:10
• @xzczd I wrote "inexact' in my comment, because that is the word that the warning message used. Perhaps, I should have used "not rationalized" or some other term instead. I shall change it to avoid confusion. Thanks. Commented Sep 6 at 14:54
Clear["*"];
Manipulate[
Module[{circle, center, radius, pointP, pointB, tangentPoint},
circle = Disk[{0, 4}, 1];
center = {0, 4};
pointP = {a^2/4, a} // Rationalize;
pointB = {-1, a} // Rationalize;
(*Distance formula setup*)
tangentPoint =
NSolve[{Sqrt[(x - center[[1]])^2 + (y - center[[2]])^2] == radius,
Sqrt[(x - pointP[[1]])^2 + (y - pointP[[2]])^2] ==
Sqrt[radius^2 + EuclideanDistance[pointP, center]^2]}, {x, y},
Reals];
tangentPoint = {x, y} /. tangentPoint;
(*Display the plot*)
Show[ContourPlot[{y^2 == 4 x, x^2 + (y - 4)^2 == 1,
x == -1}, {x, -3, 6}, {y, -8, 8},
ContourStyle -> {Blue, Thick, Dashed, Black},
PerformanceGoal -> "Quality", Frame -> False, Axes -> True,
AxesOrigin -> {0, 0}, AxesLabel -> {"x", "y"},
AspectRatio -> Automatic],
Graphics[{Red, PointSize[0.02], Point[pointP],
Text[Style["P", 12, Italic, FontFamily -> "Times"],
pointP, {-1, -1}], Black, PointSize[0.02], Point[pointB],
Text[Style["B", 12, Italic, FontFamily -> "Times"],
pointB, {1, 0}], Black, Dashed, Line[{pointP, pointB}], Black,
PointSize[0.02], Point[center],
Text[Style["A", 12, Italic, FontFamily -> "Times"],
center, {1, 0}], Black, Line[{pointP, #}] & /@ tangentPoint}],
PlotRange -> {{-3, 6}, {-8, 8}}]], {a, 0, 6}]
`