Expressions with Heads That Are Not Symbols

In most cases, you want the head f of a Wolfram Language expression like f[x] to be a single symbol. There are, however, some important applications of heads that are not symbols.

This expression has f[3] as a head. You can use heads like this to represent "indexed functions":

f[3][x,y]

You can use any expression as a head. Remember to put in the necessary parentheses:

(a+b)[x]

One case where we have already encountered the use of complicated expressions as heads is in working with pure functions in "Pure Functions". By giving (RefLink[Function, paclet:ref/Function])[vars,body] as the head of an expression, you specify a function of the arguments to be evaluated.

With the head (RefLink[Function, paclet:ref/Function])[x,x^2], the value of the expression is the square of the argument:

Function[x,x^2][a+b]

There are several constructs in the Wolfram Language which work much like pure functions, but which represent specific kinds of functions, typically numerical ones. In all cases, the basic mechanism involves giving a head which contains complete information about the function you want to use.

Some expressions which have heads that are not symbols.

(RefLink[NDSolve, paclet:ref/NDSolve]) returns a list of rules that give y as an (RefLink[InterpolatingFunction, paclet:ref/InterpolatingFunction]) object:

NDSolve[{y''[x]==y[x],y[0]==y'[0]==1},y,{x,0,5}]

Here is the (RefLink[InterpolatingFunction, paclet:ref/InterpolatingFunction]) object:

y/.First[%]

You can use the (RefLink[InterpolatingFunction, paclet:ref/InterpolatingFunction]) object as a head to get numerical approximations to values of the function y:

%[3.8]

Another important use of more complicated expressions as heads is in implementing functionals and functional operators in mathematics.

As one example, consider the operation of differentiation. As discussed in "The Representation of Derivatives", an expression like f' represents a derivative function, obtained from f by applying a functional operator to it. In the Wolfram Language, f' is represented as (RefLink[Derivative, paclet:ref/Derivative])[1][f]: the "functional operator" (RefLink[Derivative, paclet:ref/Derivative])[1] is applied to f to give another function, represented as f'.

This expression has a head which represents the application of the “functional operator” (RefLink[Derivative, paclet:ref/Derivative])[1] to the “function” f:

f'[x]//FullForm

You can replace the head f' with another head, such as fp. This effectively takes fp to be a “derivative function” obtained from f:

%/.f'->fp