Questions on the use or manipulation of Mathematica variables (i.e. names associated with a changeable value). Use [variable-definitions] or [assignment] for questions on variable context localization, or assignment.

Variable name basics:

  • Mathematica variables can have multiple letters and numbers in their names, but names are not allowed to begin with a number.

  • A generally accepted practice is to avoid starting variable names with capital letters, since Mathematica's own built-in commands and variables all begin with capital letters. Using lower-case when creating your own variables helps prevent possible conflicts with built-in commands.

Tips for creative naming (copied from a MathGroup post by David Park):

SpecialCharacters

NonPrintingCharacters

LetterSpace

TextualForms

UnderBracket

These are both Symbols and can be used as variables:

my\[LetterSpace]first\[LetterSpace]variable

my\[UnderBracket]first\[UnderBracket]variable

LetterSpace has the alias esc ls esc. UnderBracket has the alias esc u[ esc.

Another "special form" that can be used for primed and double primed symbols:

x:02b9 which gives x'

x:02ba which gives x"

These have the Head Symbol and can be used for variables. They are not confused with derivatives and the primes are at the proper level.

history | excerpt history