I can't seem to get an answer to this simple question: are greek letters
allowed as variable names in Mathematica? I have tried this with limited
success (v 5.2). It seems that some greek letters are reserved, for example
alpha. I am not sure about that. Any insight is appreciated. Thanks!
-Tony
foo[\[Alpha]_, \[ScriptA]_] := \[Alpha]*\[ScriptA]
and
foo[2, 3]
gives
6
and
foo[2, \[Beta]]
gives
2 \[Beta]
Regards
Jens
for variable names you can use all latin, greek, script and gothic
letters. Exceptions are the "one letter" functions or constants:
C, D, E, I, K, N, O and $, which are protected.
K isn't protected, but lives in the System` context and is used
internally e.g. as summation variable. It will not be cleared with
Clear["Global`*].
Gruss Peter
--
==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==
Peter Breitfeld, Bad Saulgau, Germany -- http://www.pBreitfeld.de
.....and of course greek Pi is protected too.
\[Alpha]=2;
\[Alpha]+10
12
Perhaps you're confusing some Greek letters with similarly-shaped
symbols, such as the Element symbol or the Sum symbol.
amannuc1 wrote:
> Dear Community,
>
> I can't seem to get an answer to this simple question: are greek letters
> allowed as variable names in Mathematica? I have tried this with limited
> success (v 5.2). It seems that some greek letters are reserved, for example
> alpha. I am not sure about that. Any insight is appreciated. Thanks!
>
> -Tony
>
--
Murray Eisenberg mur...@math.umass.edu
Mathematics & Statistics Dept.
Lederle Graduate Research Tower phone 413 549-1020 (H)
University of Massachusetts 413 545-2859 (W)
710 North Pleasant Street fax 413 545-1801
Amherst, MA 01003-9305
OK. Thanks. I can't seem to reproduce the problem. I will keep
learning.
-Tony
That's great. Thank you.
Is there an issue doing this with subscripts? For example, suppose my
variable is
\!\(x\_y\)
Can I put that inside a function as you have done? I am having
problems with this.
-Tony
Maybe confusing \[Alpha] with \[Proportional]? Use ESC a ESC to type alpha.
yes Subscript[x,y] is not a symbol. You can use
the Notation package to Symbolize[] it.
Regards
Jens
>Is there an issue doing this with subscripts? For example, suppose
>my variable is \!\(x\_y\)
>Can I put that inside a function as you have done? I am having
>problems with this.
With a default setup, Mathematica does not work well with
subscripted variables. A naive implementation will not work as
expected in many cases.
The head of a normal Mathematica variable is Symbol. The head of
a subscripted variable is Subscript. This difference will lead
to behavior different than what you might expect in some cases.
This can be remedied by using Symbolize in the Notation package.
But from my perspective, the advantages of subscripted variables
are out weighed by the extra effort spent making subscripted
variables work well with Mathematica's various functions.
Subscripted names are not symbols and sometimes Mathematica has
difficulties handling them as variables.
If you want to use subscripted variables, you should use the Symbolize
command from the Notation package [1, 2].
Regards,
- Jean-Marc
[1] /Notation, Symbolize and InfixNotation/
http://reference.wolfram.com/mathematica/Notation/tutorial/NotationSymbolizeAndInfixNotation.html
[2] /Symbolize/
http://reference.wolfram.com/mathematica/Notation/ref/Symbolize.html