1
$\begingroup$

I know EngineeringForm is a wrapper which prevents evaluation of content, but pasting chunks of other cells with an EngineeringForm number, got these two simple expressions w/ the same input appearance but wrong, different (complex) outputs (100.+7.55043i and 0.002815+0.000212246i). Was able to fix it only through a direct RowBoxes edit. The second is an intermediary edit of the first raw code, but still a wrong expression w/ same display. IMHO the main issue is that the wrong cell code was formed by copy and paste input and it was evaluated w/o error ! At the end of this post is the correct raw code (output: 0.02+0.254646i) you get by typing it again. My question is: How could one check the expression correctness ? If I share my cell data, how can others know the expression is corrupted ?

UPDATE: Similar problems both flagged as bugs and corrected: 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 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).

Input Expression in as in "latex 'copy as'" shows a hidden parenthesis, not present in the displayed cell expression:

$$ 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}$$

First (wrong) 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"]

Second (wrong) boxes expression:

Cell[BoxData[
RowBox[{"\[ImaginaryJ]", " ", "120", " ", "\[Pi]", " ", "28.15", " ", 
SuperscriptBox["10", 
RowBox[{"-", "6"}]], 
RowBox[{
RowBox[{"+", 
SuperscriptBox[
RowBox[{"(", 
RowBox[{"\[ImaginaryJ]", " ", "120", " ", "\[Pi]", " ", "10", " ", 
SuperscriptBox["10", 
RowBox[{"-", "3"}]]}], ")"}], 
RowBox[{"-", "1"}]]}], "+", 
FractionBox["1", "50"]}]}]], "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"]
$\endgroup$
4
  • $\begingroup$ Should the first code block end in ]? $\endgroup$
    – bbgodfrey
    Commented Nov 30, 2021 at 16:56
  • 1
    $\begingroup$ Why are you copying and pasting "chunks of other cells with an EngineeringForm number"? What are you trying to accomplish? $\endgroup$ Commented Dec 1, 2021 at 1:27
  • $\begingroup$ @bbgodfrey Thanks, corrected. $\endgroup$
    – Fernando
    Commented Dec 8, 2021 at 10:40
  • $\begingroup$ @rohit-namjoshi The whole Notebook structure was thought as to enable copying and pasting cells, etc. I won't repeat the mistake (?) of using Scientific or Engineering forms the way I did in this case, but I'll continue copying "chunks" of other cells, and they should behave the same after pasted (or give an error when evaluated). In my understanding this is similar to mathematica.stackexchange.com/q/114949/74135 $\endgroup$
    – Fernando
    Commented Dec 8, 2021 at 10:49

0

Your Answer

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