Mathematica Asked by David Bevan on July 18, 2021
Bug introduced after 5.2, fixed in 8.0, reintroduced in 9.0 and persisting through 12.3
Is this a bug?
If I do
FullSimplify[n E^(0``10 n)]
then it returns
n/2
which is obviously incorrect.
(I’ve simplified the example, following a comment.)
[Mathematica Version 10.3.1.0]
I think I've traced down the problem. It hinges on two things. An identity:
Cosh[x] == Sinh[2 x]/(2 Sinh[x]) // Simplify
(* True *)
And a questionable auto-simplification:
Csch[0``10. n] Sinh[2 0``10. n]
(* 1 *)
{Csch[0``10. n], Sinh[2 0``10. n]} // FullForm
(* List[Csch[Times[0``10.,n]],Sinh[Times[0``9.698970004336019,n]]] *)
(The coefficients are equal, so I guess that's why they are treated as identical.)
Here are the steps in which these problems arise:
n Exp@(0``10 n) // ExpToTrig
(* n (Cosh[0.*10^-10 n] + Sinh[0.*10^-10 n]) *)
n (Cosh[0``10. n] + Sinh[0``10. n]) //. SimplifyDump`CosToSinRules
(* n (1/2 + Sinh[0.*10^-10 n]) *)
Sinh[0``10. n] // FullSimplify
(* 0 *)
The simplified expression is already wrong in the second step, in which the identity is applied. The last step is questionable, too, but understandable. It's what leads to n/2
as the answer.
I, for one, feel I understand why this bug has persisted.
Maybe the best workaround is to flush all "underflowed" arbitrary-precision numbers to exact 0
:
FullSimplify[n E^(0``10 n) /. z_ /; z == 0 :> 0]
(* n *)
Answered by Michael E2 on July 18, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP