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

Documentation / Mathematica / The Mathematica Book / Principles of Mathematica / Functional Operations /

2.2.9 Advanced Topic: Working with Operators

You can think of an expression like f[x] as being formed by applying an operator f to the expression x. You can think of an expression like f[g[x]] as the result of composing the operators f and g, and applying the result to x.

Some functional operations.

This represents the composition of the functions f, g and h.

In[1]:= Composition[f, g, h]


You can manipulate compositions of functions symbolically.

In[2]:= InverseFunction[Composition[%, q]]


The composition is evaluated explicitly when you supply a specific argument.

In[3]:= %[x]


You can get the sum of two expressions in Mathematica just by typing x + y. Sometimes it is also worthwhile to consider performing operations like addition on operators.

You can think of this as containing a sum of two operators f and g.

In[4]:= (f + g)[x]


Using Through, you can convert the expression to a more explicit form.

In[5]:= Through[%, Plus]


This corresponds to the mathematical operator .

In[6]:= Identity + (D[#, x]&)


Mathematica does not automatically apply the separate pieces of the operator to an expression.

In[7]:= % [x^2]


You can use Through to apply the operator.

In[8]:= Through[%, Plus]


Operations for working with operators.

This has a complicated expression as a head.

In[9]:= t = ((1 + a)(1 + b))[x]


Functions like Expand do not automatically go inside heads of expressions.

In[10]:= Expand[%]


With the Heads option set to True, MapAll goes inside heads.

In[11]:= MapAll[Expand, t, Heads->True]


The replacement operator /. does go inside heads of expressions.

In[12]:= t /. a->1


You can use Operate to apply a function specifically to the head of an expression.

In[13]:= Operate[p, t]