6
$\begingroup$

I have found a serious bug in Mathematica 10.0.1.0 on mac os x. See the attached screenshot. It is applying the square root to the Mpc. I am very shocked by this. Does anyone know how to avoid this bug. I don't want to have to check all my calculations by hand!

To reproduce it you can copy, paste and evaluate:

 (CellPrint@#; NotebookLocate["badboxparsing"];     SelectionEvaluateCreateCell[EvaluationNotebook[]]) &@  Cell[BoxData[RowBox[{"k", "/",  RowBox[{"(",  RowBox[{"h", " ",  SuperscriptBox[ RowBox[{SuperscriptBox["Mpc",  RowBox[{"-", "1"}]], "(",  SuperscriptBox[RowBox[{ SubsuperscriptBox["\[CapitalOmega]", "m",  RowBox[{"2", "/", "3"}]], "(",  RowBox[{"1", "-", SubscriptBox["\[CapitalOmega]", "m"]}],")"}],RowBox[{"1", "/", "3"}]], ")"}], RowBox[{"1", "/", "2"}]]}], ")"}]}]], "Input",    CellTags -> "badboxparsing"] 

Update: The way the bug arises is if you have the equation in text mode and you then copy and paste into Input mode. See this file for example. Mathematica support have reproduced the bug and have filed a report on it.

screenshot of bug

Note: The bug shows up only when the subscripts are there.

$\endgroup$
  • $\begingroup$ Please post code and not images when possible $\endgroup$ – Dr. belisarius Oct 5 '14 at 5:22
  • $\begingroup$ I can't reproduce your result on Windows $\endgroup$ – RunnyKine Oct 5 '14 at 5:26
  • $\begingroup$ @belisarius I would like to post code but the bug only works when the subscripts are there and I don't know how to do subscripts in the code. I added a link to the file. $\endgroup$ – Virgo Oct 5 '14 at 5:26
  • 3
    $\begingroup$ Copy and paste and evaluate and never use subscripts again: (CellPrint@#; NotebookLocate["badboxparsing"]; SelectionEvaluateCreateCell[EvaluationNotebook[]]) &@ Cell[BoxData[RowBox[{"k", "/", RowBox[{"(", RowBox[{"h", " ", SuperscriptBox[ RowBox[{SuperscriptBox["Mpc", RowBox[{"-", "1"}]], "(", SuperscriptBox[RowBox[{ SubsuperscriptBox["\[CapitalOmega]", "m", RowBox[{"2", "/", "3"}]], "(", RowBox[{"1", "-", SubscriptBox["\[CapitalOmega]", "m"]}],")"}],RowBox[{"1", "/", "3"}]], ")"}], RowBox[{"1", "/", "2"}]]}], ")"}]}]], "Input", CellTags -> "badboxparsing"] $\endgroup$ – Rolf Mertig Oct 5 '14 at 6:13
  • 1
    $\begingroup$ I reproduced the problem as instructed in the updated question. But when I evaluated the pasted the expression Mathematica warned me about the dangers of pasting from TraditionalForm. Didn't you get this warning? $\endgroup$ – Gustavo Delfino Oct 10 '14 at 8:37
7
$\begingroup$

It's clear from the box form of the expression in the notebook you linked that there is a misplaced RowBox wrapping the Mpc together with the right parenthesis that immediately precedes the ^(1/2) power. This is then incorrectly interpreted as Mpc being inside the square root. I have no idea how this RowBox got there, but when I simply highlight this parenthesis in )^(1/2) (the one on the left) and re-type it, the expression is fixed.

It is indeed disconcerting that a malformed box form like this cannot be visually recognized as containing an error, because it prints correctly. Moreover, in this case the interpretation of the input seems to give precedence to the RowBox grouping, over the grouping of terms by matching parentheses. That cannot be right. I would file a bug report showing the following box forms hidden in your input:

DisplayForm[RowBox[{"k", "/", 
     RowBox[{"(", 
        RowBox[{"h", " ", 
           SuperscriptBox[
             RowBox[{
                SuperscriptBox["Mpc", 
                  RowBox[{"-", "1"}]], "(", 
                SuperscriptBox[
                  RowBox[{
                     SubsuperscriptBox["Ω", "m", 
                       RowBox[{"2", "/", "3"}]], "(", 
                     RowBox[{"1", "-", 
                        SubscriptBox["Ω", "m"]}], ")"}], 
                  RowBox[{"1", "/", "3"}]], ")"}], 
             RowBox[{"1", "/", "2"}]]}], ")"}]}]]

The offending RowBox is on line 5. If you execute this command and copy the output into an input cell, you reproducibly get the incorrect result mentioned in the question.

i would be curious how you managed to type in this input in the first place. Was it generated by some other low-level operation, perhaps?

$\endgroup$
  • $\begingroup$ Thank you Jens.I have already written to support about this and will point them to your post when they reply. By the way I just entered that expression by hand as far as I remember. The only defense I can think of is always to put in an explicit * whenever I have a symbol next to brackets. Hopefully that works, I am really disappointed about this. $\endgroup$ – Virgo Oct 5 '14 at 6:05
  • 3
    $\begingroup$ @Jens by editing in the frontend one can get weird things. Parsing then sometimes results in true errors. The only way out is to not use subscripts (which I usually do since a long time). $\endgroup$ – Rolf Mertig Oct 5 '14 at 6:17
  • $\begingroup$ On second thoughts, its possible I copied and pasted part of the expression from another part of the notebook as I don't seem to get the bug when I enter the expression completely by hand. I still think it is a very serious bug which I hope they fix soon. $\endgroup$ – Virgo Oct 5 '14 at 6:45
  • 4
    $\begingroup$ @RolfMertig That's indeed good advice. Subscripts are in general full of pitfalls, especially for people who don't know anything about DownValues... But this seems to be a good test case showing a shortcoming of the parser that looks fixable. $\endgroup$ – Jens Oct 5 '14 at 7:08
  • $\begingroup$ @Jens I have updated the post with how to get the bug by copying and pasting a text expression. $\endgroup$ – Virgo Oct 10 '14 at 1:38

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.