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.
|Composition[f, g, ... ] ||the composition of functions f, g, ... |
|InverseFunction[f] ||the inverse of a function f |
|Identity ||the identity function |
|This represents the composition of the functions f, g and h. || |
Composition[f, g, h]
|You can manipulate compositions of functions symbolically. || |
|The composition is evaluated explicitly when you supply a specific argument. || |
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. || |
|Using Through, you can convert the expression to a more explicit form. || |
|This corresponds to the mathematical operator . || |
Identity + (D[#, x]&)
|Mathematica does not automatically apply the separate pieces of the operator to an expression. || |
|You can use Through to apply the operator. || |
Operations for working with operators.
|Identity[expr] ||the identity function |
|Through[p[, ][x], q] ||give p[[x], [x]] if p is the same as q |
|Operate[p, f[x]] ||give p[f][x] |
|Operate[p, f[x], n] ||apply p at level n in f |
|MapAll[p, expr, Heads->True] ||apply p to all parts of expr, including heads |
|This has a complicated expression as a head. || |
t = ((1 + a)(1 + b))[x]
|Functions like Expand do not automatically go inside heads of expressions. || |
|With the Heads option set to True, MapAll goes inside heads. || |
MapAll[Expand, t, Heads->True]
|The replacement operator /. does go inside heads of expressions. || |
|You can use Operate to apply a function specifically to the head of an expression. || |