Message Boards Message Boards

0
|
3588 Views
|
4 Replies
|
2 Total Likes
View groups...
Share
Share this post:

Working with indexing?

Posted 2 years ago

Hello everybody, please have a look at the following:

In[1]:= Subscript[\[Sigma], Subscript[K, Euler]] = 10

Out[1]= 10

In[2]:= \[Sigma] = 5

Out[2]= 5

In[3]:= Subscript[\[Sigma], Subscript[K, Euler]]/\[Sigma]

Out[3]= Subscript[5, Subscript[K, Euler]]/5

As a photo too, because i think it is better visible then:

code visible

Does sombody have an idea on how to stop this problem and why it occurs. For me it is kind of mandatory to use those index.

Greetings Christoph

POSTED BY: Christoph W
4 Replies
Posted 2 years ago

As you've noticed there are odd things that can happen using subscripts (and superscripts) in calculations. The solution: Don't use subscript and superscripts in calculations.

But you can have the desired effect (which was posted recently either in this forum or Mathematica.StackExchange - I can't find it at the moment) using the Format statement.

Format[\[Sigma]KEuler, Subscript[\[Sigma], Subscript[K, Euler]]];
\[Sigma]KEuler = 10;
\[Sigma] = 5;
\[Sigma]KEuler/\[Sigma]
(* 2 *)
POSTED BY: Jim Baldwin

This support article addresses the issue of variables with subscripts and superscripts: https://support.wolfram.com/43606

POSTED BY: Jesse Friedman
Posted 2 years ago

The issue can also be fixed when naming Sigma into Sigma_Something

POSTED BY: Christoph W
Posted 2 years ago

But an underscore isn't a legitimate part of a variable name.

POSTED BY: Jim Baldwin
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract