SymbolΒΆ

Symbols are one of the basic types manipulated by FriCAS. The Symbol domain provides ways to create symbols of many varieties.

The simplest way to create a symbol is to “single quote” an identifier.

X: Symbol := 'x
  x
                                  Type: Symbol

This gives the symbol even if x has been assigned a value. If x has not been assigned a value, then it is possible to omit the quote.

XX: Symbol := x
  x
                                  Type: Symbol

Declarations must be used when working with symbols, because otherwise the interpreter tries to place values in a more specialized type Variable.

A := 'a
  a
                                  Type: Variable a

B := b
  b
                                  Type: Variable b

The normal way of entering polynomials uses this fact.

x**2 + 1
   2
  x  + 1
                                  Type: Polynomial Integer

Another convenient way to create symbols is to convert a string. This is useful when the name is to be constructed by a program.

"Hello"::Symbol
  Hello
                                  Type: Symbol

Sometimes it is necessary to generate new unique symbols, for example, to name constants of integration. The expression new() generates a symbol starting with %.

new()$Symbol
  %A
                                  Type: Symbol

Successive calls to new produce different symbols.

new()$Symbol
  %B
                                  Type: Symbol

The expression new(“s”) produces a symbol starting with %s.

new("xyz")$Symbol
  %xyz0
                                  Type: Symbol

A symbol can be adorned in various ways. The most basic thing is applying a symbol to a list of subscripts.

X[i,j]
   x
    i,j
                                  Type: Symbol

Somewhat less pretty is to attach subscripts, superscripts or arguments.

U := subscript(u, [1,2,1,2])
   u
    1,2,1,2
                                  Type: Symbol

V := superscript(v, [n])
    n
   v
                                  Type: Symbol

P := argscript(p, [t])
  p(t)
                                  Type: Symbol

It is possible to test whether a symbol has scripts using the scripted? test.

scripted? U
  true
                                  Type: Boolean

scripted? X
  false
                                  Type: Boolean

If a symbol is not scripted, then it may be converted to a string.

string X
  "x"
                                  Type: String

The basic parts can always be extracted using the name and scripts operations.

name U
  u
                                  Type: Symbol

scripts U
  [sub= [1,2,1,2],sup= [],presup= [],presub= [],args= []]
                Type: Record(sub: List OutputForm,
                             sup: List OutputForm,
                             presup: List OutputForm,
                             presub: List OutputForm,
                             args: List OutputForm)

name X
  x
                                  Type: Symbol

scripts X
  [sub= [],sup= [],presup= [],presub= [],args= []]
                Type: Record(sub: List OutputForm,
                             sup: List OutputForm,
                             presup: List OutputForm,
                             presub: List OutputForm,
                             args: List OutputForm)

The most general form is obtained using the script operation. This operation takes an argument which is a list containing, in this order, lists of subscripts, superscripts, presuperscripts, presubscripts and arguments to a symbol.

M := script(Mammoth, [ [i,j],[k,l],[0,1],[2],[u,v,w] ])
   0,1       k,l
      Mammoth   (u,v,w)
     2       i,j
                                  Type: Symbol

scripts M
  [sub= [i,j],sup= [k,l],presup= [0,1],presub= [2],args= [u,v,w]]
                Type: Record(sub: List OutputForm,
                             sup: List OutputForm,
                             presup: List OutputForm,
                             presub: List OutputForm,
                             args: List OutputForm)

If trailing lists of scripts are omitted, they are assumed to be empty.

N := script(Nut, [ [i,j],[k,l],[0,1] ])
   0,1   k,l
      Nut
         i,j
                                  Type: Symbol

scripts N
  [sub= [i,j],sup= [k,l],presup= [0,1],presub= [],args= []]
                Type: Record(sub: List OutputForm,
                             sup: List OutputForm,
                             presup: List OutputForm,
                             presub: List OutputForm,
                             args: List OutputForm)

See Also:

  • )show Symbol

Table Of Contents

This Page