Ask Your Question
1

Mathematica misinterprets some underscored symbolic variables

asked 2018-03-21 08:25:24 +0100

bekalph gravatar image

updated 2018-03-21 08:29:56 +0100

Following examples show that the interface between sage and Mathematica misinterprets symbolic variables if they are underscored with numbers:

sage: h_20,h_10,h_2,h_3,h20,h10,h_ij,h_kl=var("h_20,h_10,h_2,h_3,h20,h10,h_ij,h_kl");
sage: mexpr=mathematica((h_20+h_10)^3);
sage: print(mexpr);
                3
     27000 (h_)
sage: mexpr1=mathematica((h20+h10)^3);
sage: print(mexpr1);
                3
     (h10 + h20)
sage: mexpr2=mathematica((h_2+h_3)^3);
sage: print(mexpr2);
             3
     125 (h_)
sage: mexpr3=mathematica((h_ij+h_kl)^3);
sage: print(mexpr3);
                      3
     ((h_ij) + (h_kl))

I use sage-8.1 and Mathematica 11.2.0 at Linux OpenSUSE Leap v42.3. In this forum I haven't found any other comment regarding this funny behaviour.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2018-03-22 19:43:35 +0100

DanialBagh gravatar image

I'm not entirely sure but I think Mathematica doesn't like underlines, so instead of defining variables like A_ij I would define Aij. You just have to adhere to naming conventions in both Mathematica and Sage, so something like Aij would be acceptable in both, I think.

edit flag offensive delete link more

Comments

I agree, The best method to circumvent this problem is substituting the "_"- symbol by unique identifiers in sage and subsequently replacing them in Mathematica by its appropriate underscoring. key combination. This workaround should be applied to all kinds of underscored symbols (not only for underscored numbers).

bekalph gravatar imagebekalph ( 2018-03-22 21:37:27 +0100 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2018-03-21 08:25:24 +0100

Seen: 365 times

Last updated: Mar 22 '18