Search code examples
maximawxmaxima

wxMaxima: subindexed variables in functions work when written as "x_1" but not when written as "x[1]"


I'm having trouble defining a function in terms of variables with subindices. Using the makelist command I can create an unspecified function that depends upon the subindexed variables x[1] and x[2]. However, when I try to give an expression to that function, wxMaxima does not allow it:

enter image description here

On the other hand, if I write the subindexed variables as x_1 and x_2 instead of x[1] and x_[2], things do work.

enter image description here

What is the reason for this behavior? Aren't the two subindexing methods equivalent in terms of functions?


Solution

  • Only symbols can be declared function arguments. In particular, subscripted expressions are not symbols and therefore can't be function arguments.

    WxMaxima displays symbols which end in a number, e.g., x_1, the same as subscripted expressions, e.g., x[1]. This is intended as a convenience, although it is confusing because it makes it difficult to distinguish the two.

    You can see the internal form of an expression via ?print (note the question mark is part of the name). E.g., ?print(x_1); versus ?print(x[1]);.