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 = new Variable('x');
xPlus = new Plus(x, 1);
xMinus = new Minus(x, 1);
fExpr = new Vector([x, xPlus, xMinus]); // Transforms x to 3-dimensional vector
f = new CustomFunction('f', [x], fExpr); // Creates a function R -> R^3 from fExpr
y = new Variable('z');
z = new Variable('y');
gExpr = x + y + z; // Transforms 3-dimensional input to real value
g = new CustomFunction('g', [x, y, z], gExpr) // Creates a function R^3 -> R from gExpr
a composition can be created as follows:
composite = new CompositeFunction(f, g); // R -> R
// composite(2) = 6
Source
CompositeFunction(MathFunction f, MathFunction g):
super('comp(${f.name},${g.name})', f.args) {
this.f = f;
this.g = g;
}