Group Abstract Group Abstract

Message Boards Message Boards

0
|
33 Views
|
3 Replies
|
4 Total Likes
View groups...
Share
Share this post:

Inconsistent calculations when simplifying two equal terms

Posted 1 day ago

See attached notebook. Why doesn't ans1 equal ans2? ans1 is the correct answer.

POSTED BY: John Kubala
3 Replies

You probably expect SetPrecision to behave like ResourceFunction["DecimalRound"]. They behave differently.

POSTED BY: Gianluca Gorni
Posted 10 hours ago

One of the issues has to do with the precision(s) being used in the computations.

In numerical analysis, there are the phenomena of "roundoff error" and "error propagation." In physical science, these go under the name of "significant figures" or "sig figs" for short. In both, the bugbear is subtracting quantities that are close in magnitude. When the loss of precision is immense, it is sometimes called "catastrophic cancellation."

In γMinus1 = γ - 1, γ is close to 1. Further, the precision of γ has been reduced to 9. The difference γ - 1 loses almost 7 sig figs, so that γMinus1 has just over 2 sig figs. Hence the result is displayed as 3.5 * 10^(-7). As David Trimas pointed out, the result should be 3.47222… instead of 3.5.

We can see the effect of cancellation in ans1 and ans2:

{(3.5*10^-7)*c^2 , 0.5*u^2}//QuantityMagnitude//InputForm
(*   {3.15*^10, 3.125*^10}  *)

{(3.47222403*10^-7)*c^2 , 0.5*u^2}//QuantityMagnitude//InputForm
(*   {3.125001627*^10, 3.125*^10}  *)

The two terms being subtracted are nearly the same, and a small difference in the first term of each pair, makes a much larger difference between the answers ans1 and ans2.

Given that the mantissa 3.5 was obtained by rounding to 2 sig figs, it potentially represents a true value between 3.45 and 3.55, and the "answer" might lie between these values

((3.45*10^-7)*c^2 - 0.5*u^2)/((3.45/10^7)*c^2)
((3.55*10^-7)*c^2 - 0.5*u^2)/((3.55/10^7)*c^2)
(*
-0.00644122
0.0219092
*)

Personally, I would say that 5.20833363*10^-7 is the correct answer, which is close to ans2, based on symbolically simplifying the formula to

(1/2)(u^2/c^2 + u^2/(c (c + Sqrt[c^2 - u^2])))
POSTED BY: Updating Name

Look at

γMinus1 // FullForm
(*3.472224030520721`*^-7*)

It is not exactly 3.5*^-7 .

POSTED BY: David Trimas
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard