This is documentation for Mathematica 4, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.2)
Wolfram Research, Inc.

ContentsApplying Functions Repeatedly

2.2.1 Function Names as Expressions

In an expression like f[x], the "function name" f is itself an expression, and you can treat it as you would any other expression.

You can replace names of functions using transformation rules.

In[1]:= f[x] + f[1 - x] /. f -> g


Any assignments you have made are used on function names.

In[2]:= p1 = p2; p1[x, y]


This defines a function which takes a function name as an argument.

In[3]:= pf[f_, x_] := f[x] + f[1 - x]

This gives Log as the function name to use.

In[4]:= pf[Log, q]


The ability to treat the names of functions just like other kinds of expressions is an important consequence of the symbolic nature of the Mathematica language. It makes possible the whole range of functional operations discussed in the sections that follow.

Ordinary Mathematica functions such as Log or Integrate typically operate on data such as numbers and algebraic expressions. Mathematica functions that represent functional operations, however, can operate not only on ordinary data, but also on functions themselves. Thus, for example, the functional operation InverseFunction takes a Mathematica function name as an argument, and represents the inverse of that function.

InverseFunction is a functional operation: it takes a Mathematica function as an argument, and returns another function which represents its inverse.

In[5]:= InverseFunction[ArcSin]


The result obtained from InverseFunction is a function which you can apply to data.

In[6]:= %[x]


You can also use InverseFunction in a purely symbolic way.

In[7]:= InverseFunction[f] [x]


There are many kinds of functional operations in Mathematica. Some represent mathematical operations; others represent various kinds of procedures and algorithms.

Unless you are familiar with advanced symbolic languages, you will probably not recognize most of the functional operations discussed in the sections that follow. At first, the operations may seem difficult to understand. But it is worth persisting. Functional operations provide one of the most conceptually and practically efficient ways to use Mathematica.

ContentsApplying Functions Repeatedly