First time here? Check out the FAQ!

Ask Your Question
1

Mathematica misinterprets some underscored symbolic variables

asked 7 years ago

bekalph gravatar image

updated 7 years ago

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.

Preview: (hide)

1 Answer

Sort by » oldest newest most voted
0

answered 7 years ago

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.

Preview: (hide)
link

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 ( 7 years ago )

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: 7 years ago

Seen: 378 times

Last updated: Mar 22 '18