Ask Your Question
1

Mathematica misinterprets some underscored symbolic variables

asked 2018-03-21 02:25:24 -0500

bekalph gravatar image

updated 2018-03-21 02:29:56 -0500

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 13:43:35 -0500

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 15:37:27 -0500 )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 02:25:24 -0500

Seen: 44 times

Last updated: Mar 22