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:

Composition[f,g,h]

You can manipulate compositions of functions symbolically:

InverseFunction[Composition[%,q]]

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

%[x]

Composition can be entered using the operator @*:

f @* g @* h

(RefLink[RightComposition, paclet:ref/RightComposition]) composes in the opposite order:

RightComposition[f,g,h]

Composition on the right can be entered using the operator /*

f/*g/*h

You can get the sum of two expressions in the Wolfram System 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:

(f+g)[x]

Using (RefLink[Through, paclet:ref/Through]), you can convert the expression to a more explicit form:

Through[%,Plus]

This corresponds to the mathematical operator 1+(∂/(∂x)):

Identity+(D[#,x]&)

The Wolfram System does not automatically apply the separate pieces of the operator to an expression:

%[x^2]

You can use (RefLink[Through, paclet:ref/Through]) to apply the operator:

Through[%,Plus]

Operations for working with operators.

This has a complicated expression as a head:

t=((1+a)(1+b))[x]

Functions like (RefLink[Expand, paclet:ref/Expand]) do not automatically go inside heads of expressions:

Expand[%]

With the (RefLink[Heads, paclet:ref/Heads]) option set to (RefLink[True, paclet:ref/True]), (RefLink[MapAll, paclet:ref/MapAll]) goes inside heads:

MapAll[Expand,t,Heads->True]

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

t/.a->1

You can use (RefLink[Operate, paclet:ref/Operate]) to apply a function specifically to the head of an expression:

Operate[p,t]