Message Boards Message Boards

0
|
1530 Views
|
0 Replies
|
0 Total Likes
View groups...
Share
Share this post:

Incorrect notebook expression after copy and paste (but kept same display!)

Posted 2 years ago

Wrong cell code was formed by copying parts of expressions (copied expression was using EngeneeringForm). Displayed expression was correct, but output was completely wrong.

My question is: How could I know it was a wrong result ? If I share my cell data, how can others know the expression is corrupted ? Can we trust what Mathematica displays in notebook expressions ?

Similar problems, both flagged as bugs and corrected: https://mathematica.stackexchange.com/q/114949/74135 : Why a function returns two different values if copied into a Notebook or imported with Get from a Wolfram Mathematica Package? (no error indication) and https://mathematica.stackexchange.com/q/982/74135 : How to find pieces of code responsible for syntax errors? (here a syntax error was indicated, but the Boxes problem seems to be quite similar).

Problem Details:

The low-level error is due to hidden parenthesis that only shows up in a latex "copy as" output:

$ i 120 \pi \left(\frac{28.15}{10^6}+\frac{1}{\frac{i 120 \pi 10}{10^3}}+\frac{1}{50}\right)$

The displayed (and correct) expression have no parenthesis:

$ i 120 \pi 28.15 \times 10^{-6}+\frac{1}{\displaystyle i 120 \pi 10\times 10^{-3}}+\frac{1}{50}$

Problem lies on inconsistent (pasted) boxes expression :

Cell[BoxData[
RowBox[{"\[ImaginaryJ]", " ", "120", " ", "\[Pi]", 
TagBox[
RowBox[{
RowBox[{"(", 
RowBox[{"28.1448", " ", 
SuperscriptBox["10", 
RowBox[{"-", "6"}]]}], ")"}], "+", 
FractionBox[
StyleBox["1",
ShowStringCharacters->False], 
RowBox[{"\[ImaginaryJ]", " ", "120", " ", "\[Pi]", " ", "10", " ", 
SuperscriptBox["10", 
RowBox[{"-", "3"}]]}]], "+", 
FractionBox["1", "50"]}],
EngineeringForm]}]], "Input"

Correct boxes expression:

Cell[BoxData[
RowBox[{
RowBox[{"\[ImaginaryJ]", " ", "120", "\[Pi]", " ", "28.15", " ", 
SuperscriptBox["10", 
RowBox[{"-", "6"}]]}], "+", 
SuperscriptBox[
RowBox[{"(", 
RowBox[{"\[ImaginaryJ]", " ", "120", "\[Pi]", " ", "10", " ", 
SuperscriptBox["10", 
RowBox[{"-", "3"}]]}], ")"}], 
RowBox[{"-", "1"}]], "+", 
FractionBox["1", "50"]}]], "Input"]

Thanks!

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

Group Abstract Group Abstract