Group Abstract Group Abstract

Message Boards Message Boards

0
|
12.9K Views
|
3 Replies
|
0 Total Likes
View groups...
Share
Share this post:

Understand colors of variables in Wolfram Language?

Suppose that I have an code which goes like this:

yp = 2;
y_p= 2;
a = x + yp + y_p; 

Please put y with subscript p, NOT Subscript[y, p].

Usually, once the variable is defined it will be of blue color and once it executed (by pressing Shift+ Enter) it will change color to black. But, you can see that x and yp change to black, but Subscript[y, p] still remain in the same color. Why is this so? Is it default in Mathematica that if you use the subscripts as variable, the color will not change after execution? I am attaching the Mathematica file for your references.

Thanks in advance...

Attachments:
POSTED BY: Sreeraj T
3 Replies

Thanks Sander Huisman and George Woodrow III for that answer.

I can understand that if variables is starting with number, then it cannot be evaluated. But in my case, it is getting evaluated!

sreeraj t

POSTED BY: Sreeraj T

Using underscores does indeed not work; variables can not include underscores and can not start with a number. Also do not use Subscript or Superscript for variables, these should be used only as a typographical construct. Sooner or later you will get into trouble with those...

POSTED BY: Sander Huisman

Underlines are not allowed in variable names in Wolfram Language. I know that this is legal in other languages, and even a common idiom, but the underscore has a special meaning in Mathematica.

If you don't like the typesetting construct Subscript[], then you can make up your own convention, as long as it does not involve underscores.

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