protected override Expression TransformFunction(FunctionExpression functionExpression) { DifferentiationRule rule; if (_rules.TryGetValue(functionExpression.Function, out rule)) { return(rule(this, functionExpression)); } UserFunction userFunction = functionExpression.Function as UserFunction; if (userFunction != null) { VariableValuePair[] values = userFunction.Arguments. Zip(functionExpression, (variable, value) => new VariableValuePair(variable, value)). ToArray(); SubstituteTransformation transformation = new SubstituteTransformation(values); return(Transform(transformation.Transform(userFunction.Expression))); } return(functionExpression.Differentiate(_variable)); }