I have a problem where if I multiply two variables a c in Mathematica, then copy as LaTeX (or just use the Mathematica output) to get a c, then put it in ToExpression["a c",TeXForm], I get ac i.e. a new variable called ac not my original a c. But putting in 4 a c for example gives the expected output.
a=...
c=...
test1=a c
a c
test2=ToExpression["a c",TeXForm]
ac
test3=4 a c
4 a c
test4=ToExpression["4 a c",TeXForm]
4 a c
a=1
c=2
N[test1]
2.
N[test2]
ac
N[test3]
8.
N[test4]
8.
Ideally I would like to put a very big expression from Mathematica into Latex, make some edits in Latex to make it more readable, then put it back into Mathematica and put dummy values in to make sure my edits were all mathematically correct. I am also not sure what the . means in the 2. and 8. and would like to know. I am using Mathematica version 12.1 student edition but got the same result on Mathematica 11.3 student version.
I have tried putting in HoldForm and get the same result. I have also tried other pairs of letters and they all give the same result. I haven't tried this on another device yet so maybe it's just my computer. I can't believe that if this is a bug, it hasn't been detected sooner due to how simple this is so can only assume I've done something wrong.
So my question is what is wrong with my code? If nothing is wrong and this is just a quirk/bug of Mathematica then is there another way I can export from LaTeX to Mathematica and preserve correctness?
Any help would be appreciated thanks.
N
function attempts to turn an exact integer or rational expression into a machine precision floating point decimal expression. N[2] turns the exact integer2
into the decimal floating point approximate2.000000
TryN[113/728]
and see that it becomes a decimal number with a.
in it. LikewiseN[128/4]
Mathematica sometimes handles approximate decimal numbers differently from exact integer or rational numbers which have no.
$\endgroup$