There are many functions in Macaulay 2 that do various things. You can get a brief indication of what a function does by typing its name.
i1 : sin
o1 = sin
o1 : CompiledFunction
|
In this case, we see that the function
sin takes a single argument
x. We apply a function to its argument by typing them in adjacent positions. It is possible but not necessary to place parentheses around the argument.
i2 : sin 1.2
o2 = 0.932039
o2 : RR
|
i3 : sin(1.2)
o3 = 0.932039
o3 : RR
|
i4 : sin(1.0+0.2)
o4 = 0.932039
o4 : RR
|
In parsing the operator
^ takes precedence over adjacency, so the function is applied after the power is computed in the following code. This may not be what you expect.
Some functions take more than one argument, and the arguments are separated by a comma, and then parentheses are needed.
i6 : append
o6 = append
o6 : CompiledFunction
|
i7 : append({a,b,c},d)
o7 = {a, b, c, d}
o7 : List
|
Some functions take a variable number of arguments.
i8 : join
o8 = join
o8 : CompiledFunction
|
i9 : join({a,b},{c,d},{e,f},{g,h,i})
o9 = {a, b, c, d, e, f, g, h, i}
o9 : List
|
Functions, like anything else, can be assigned to variables. You may do this to provide handy private abbreviations.
i10 : ap = append;
|
i11 : ap({a,b,c},d)
o11 = {a, b, c, d}
o11 : List
|