The operators for function addition and subtraction are + and
-, while the
operators for function multiplication and division are &* and &/
respectively. The operator for function composition is <>.
Operator | Definition |
h = f + g | f(x) = f(x) + g(x) |
h = f - g | f(x) = f(x) - g(x) |
h = f &* g | f(x) = f(x) * g(x) |
h = f &/ g | f(x) = f(x) / g(x) |
h = f <> g | f(x) = f(g(x)) |
h = -f | f(x) = -f(x) |
For f <> g, the number of output arguments of g should be the same as the number of input arguments of f.
For example
>> f = sin + cos; >> f(pi/4) 1.414213562 >> p = sin &* cos; >> p(pi/4) 0.5 >> g = sin - cos; >> g(pi/4) -1.110223025e-16 >> h = log <> sin; >> h(pi/2) 0Note that in the above, f and g don't have to be both `real' functions - they can be pseudo functions, or anything that can be used as functions, such as numbers or matrices. If either operand is a function, the operation will create a new pseudo function. For example
f = sin + 2will create a function f(x) = sin(x) + 2x. Note that 2 as a function means x -> 2x instead of x -> 2.
oz 2009-12-22