protected override Expression TransformFunction(FunctionExpression functionExpression) { if (functionExpression.Function == Operators.Diff) { VariableListExtractor extractor = new VariableListExtractor(); extractor.Visit(functionExpression[1]); IReadOnlyList <Variable> variables = extractor.Variables; if (variables.Count == 0) { throw new InvalidOperationException("Cannot calculate derivative by constant"); } throw new NotImplementedException(); } if (functionExpression.Function == Operators.Plus) { return(Transform(functionExpression[0])); } if (functionExpression.Function is Operator) { SumAggregator aggregator = new SumAggregator(); aggregator.VisitFunction(functionExpression); return(aggregator.ToExpression()); } return(functionExpression.Function.Apply(functionExpression.Select(Transform))); }