0
$\begingroup$

Consider the following code:

ROffAxisArb[θ_, ztodet_] = ztodet*Tan[θ];
circle[ztodet_, θ_] := 
  Circle[{0, 0}, ROffAxisArb[θ, ztodet]];
rectangle[xtodet_, ytodet_, dxdet_, dydet_] := 
  Rectangle[{xtodet - dxdet/2, ytodet - dydet/2}, {xtodet + dxdet/2, 
    ytodet + dydet/2}];
xtodetValue = 0.;
ytodetValue = 0.;
dxdetValue = 5.;
dydetValue = 5.;
ztodetValue = 8.7 + 3.;
intersection = 
 RegionIntersection[
  rectangle[xtodetValue, ytodetValue, dxdetValue, dydetValue], 
  circle[ztodetValue, 0.25]]
ArcLength[
 RegionIntersection[
  rectangle[xtodetValue, ytodetValue, dxdetValue, dydetValue], 
  circle[ztodetValue, 0.25]]]

I would expect that if a least one number entering the evaluation is with . in the end, ArcLength should return a numeric value. In Mathematica 11.1 it really gives so. In contrast, in Mathematica 12.2 it gives

(1178357340 (ArcSin[98607293/117835734] - 
   ArcSin[Sqrt[4161861974530907]/117835734]))/98607293 

Could you please tell me whether it is possible to get the numerical value apart from entering all the numbers with .?

$\endgroup$
4
  • 1
    $\begingroup$ The default WorkingPrecision for ArcLength must have changed. Use ArcLength[RegionIntersection[rectangle[xtodetValue, ytodetValue, dxdetValue, dydetValue], circle[ztodetValue, 0.25]], WorkingPrecision -> MachinePrecision] $\endgroup$
    – Bob Hanlon
    Mar 11 at 15:24
  • $\begingroup$ Try to add ...//N after your code. $\endgroup$ Mar 11 at 15:44
  • $\begingroup$ @AlexeiBoulbitch : yes, but is it possible to solve this issue without adding? $\endgroup$ Mar 11 at 15:55
  • 1
    $\begingroup$ It seems that RegionIntersection will always return a result with rational numbers. Bob's solution with WorkingPrecision is faster than applying N afterwards. You could evaluate SetOptions[ArcLength, WorkingPrecision -> MachinePrecision] $\endgroup$
    – Jason B.
    Mar 11 at 16:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.