Why is this evaluation halved when adding units?

Bug introduced in 9.0 or earlier and persisting through 11.2 or later

Why does this strange behavior occur when dealing with units and quantities?

A[t_] := A0 Exp[-b t / (2m)]

FullSimplify[A[Quantity[0, "Seconds"]]]

 A0
--                                            (* wrong; should be A0 *)
2

b = Quantity[7, "Newtons"*"Seconds"/"Meters"]

7 second newtons per meter

m = Quantity[10, "Kilograms"]

10 kilograms

FullSimplify[A[Quantity[0, "Seconds"]]]

A0                                            (* right *)


I can imagine it spitting out an error because Exp[Quantity[0, "Seconds"]] doesn't make sense, but where does the 1/2 come from?

I don't think it's from the 2 in -b t / (2 m); changing this to -b t / (7m) gives the same result.

• Has to be a bug. – David G. Stork Jan 11 '15 at 6:21
• The bug seems to be in FullSimplify (which always tries harder). Compare A[Quantity[0, "Seconds"]]; Simplify@A[Quantity[0, "Seconds"]]; FullSimplify@A[Quantity[0, "Seconds"]] screen shot: !Mathematica graphics – Nasser Jan 11 '15 at 9:22
• I marked this as a bug. A reduced example: x*E^Quantity[0, "Feet"] // FullSimplify – Mr.Wizard Jan 11 '15 at 10:12
• @Mr.Wizard Well honestly, what do you expect from E^Quantity[0, "Feet"]? Exponents are dimensionless quantities, and raising something to a number of feet (even if it's zero) doesn't really make sense, so I wouldn't expect Mathematica to do anything sensible (in fact, an error would be nice). That being said, in the equation in the example, the remaining variables are still able to cancel out the units, so I don't really know what to expect in that case. – Martin Ender Jan 11 '15 at 15:19
• I still occasionally use the deprecated package <<PhysicalConstants, so if this (apparent) bug is cause for worry, you can always switch to the old package, which I've never had trouble with. – DumpsterDoofus Jan 11 '15 at 15:41

It is because a transformation rule in the SimplifyDump context is written without taking into account that Mathematica currently doesn't simplify zeroed Quantitiy expressions to a plain zero, which prevents the rule from detecting a division by zero. This happens even in the case where the Quantity has a correct unit, such as radians. Other than these (fatal) failings, the transformation appears correct.

In[1]:= xpr = z Exp@Quantity[0, "rad"]
ExpToTrig@xpr
FullSimplify@xpr; SimplifyDumpCosToSinRules[[-4]]
%% /. %

SimplifyDumpx_?(InternalLiterallyAbsentQ[#1, {Complex,
With[{SimplifyDumpe = Sinh[2 SimplifyDumpx]/(
2 Sinh[SimplifyDumpx])},
SimplifyDumpe /; SimplifyDumpnonsingular[SimplifyDumpe]]