private Function CalculateAnalyticDerivative() { ExpressionTree diffTree = AnalyticDifferentiator.Differentiate(_expressionTree, _expressionTree.Variables[0]); switch (diffTree.Variables.Length) { case 0: return(new Constant(diffTree.ToString())); case 1: return(new Explicit2DFunction(diffTree)); default: throw new InvalidOperationException(); } }
private Function CalculateAnalyticDerivative() { string formula = String.Format("-(({0})/({1}))", AnalyticDifferentiator.Differentiate(_expressionTree, _expressionTree.Variables[0]), AnalyticDifferentiator.Differentiate(_expressionTree, _expressionTree.Variables[1])); ExpressionTree diffTree = new ExpressionTree(formula); switch (diffTree.Variables.Length) { case 0: return(new Constant(diffTree.ToString())); case 1: return(new Explicit2DFunction(diffTree.ToString())); case 2: return(new Implicit2DFunction(diffTree.ToString())); default: throw new InvalidOperationException(); } }