CompositeFunction constructor
CompositeFunction(
- MathFunction f,
- MathFunction g
Creates a function composition.
For example, given f(x): R -> R^3
and g(x,y,z): R^3 -> R
the composition yields (g ° f)(x): R -> R^3 -> R
. First
f
is applied, then g
is applied.
Given some requirements
x = Variable('x');
xPlus = Plus(x, 1);
xMinus = Minus(x, 1);
fExpr = Vector([x, xPlus, xMinus]); // Transforms x to 3-dimensional vector
f = CustomFunction('f', [x], fExpr); // Creates a function R -> R^3 from fExpr
y = Variable('z');
z = Variable('y');
gExpr = x + y + z; // Transforms 3-dimensional input to real value
g = CustomFunction('g', [x, y, z], gExpr) // Creates a function R^3 -> R from gExpr
a composition can be created as follows:
composite = CompositeFunction(f, g); // R -> R
// composite(2) = 6
Implementation
CompositeFunction(this.f, this.g)
: super('comp(${f.name},${g.name})', f.args);