Total has been changed in Mathematica 12.0. The documentation seems to contradict itself. In one line it states:

Total[ $f[ e_1,e_2,...]$ ] gives the sum of the $e_i$ for any head $f$

In the next line one reads:

By default, Total only adds up elements inside List, SparseArray, StructuredArray and Association.

As a matter of fact, in Mathematica 12.0 Total[ f[a,b] ] does not evaluate to a+b as it did in Mathematica 11.3. Instead, the new option AllowedHeads was introduced and one can for example write now Total[f[a,b], AllowedHeads->Inherited] for obtaining the old output.

This is a breaking change. I wonder if this was intended by Wolfram?

  • 7
    $\begingroup$ Given that the option AllowedHeads is illegal in V11.3 and permissible now in V12, I'd say the change was clearly intended. You could use SetOptions[Total, AllowedHeads -> Inherited] as a general workaround. (It seems the documentation could use a good copy editor.) $\endgroup$
    – Michael E2
    Commented May 22, 2019 at 16:00
  • 7
    $\begingroup$ Consider adding this here $\endgroup$
    – Michael E2
    Commented May 22, 2019 at 16:01
  • 7
    $\begingroup$ I've always thought the M11 behavior was just a bug, and a pain to workaround. $\endgroup$
    – Carl Woll
    Commented May 22, 2019 at 17:53
  • 2
    $\begingroup$ @CarlWoll No, it was a feature not a bug. Total[expr] was supposed to be equivalent to Plus @@ epxr. $\endgroup$ Commented May 23, 2019 at 8:10
  • 2
    $\begingroup$ Please always use full version numbers. There is no Mathematica 11, but there are 11.0, 11.1, etc. I corrected this in the post for now. $\endgroup$
    – Szabolcs
    Commented May 23, 2019 at 8:19


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.