/// <summary> /// Calculates derivation tree /// </summary> /// <param name="tree">Tree to calculate</param> /// <param name="variableName">Name of variable</param> /// <returns>Tree of derivation</returns> static public ObjectFormulaTree Derivation(this ObjectFormulaTree tree, string variableName) { if (tree.Operation is IDerivationOperation) { IDerivationOperation op = tree.Operation as IDerivationOperation; return(op.Derivation(tree, variableName)); } if (ElementaryBinaryOperation.IsInteger(tree.Operation.ReturnType)) { ElementaryRealConstant op = new ElementaryRealConstant(0); return(new ObjectFormulaTree(op, new List <ObjectFormulaTree>())); } if (tree.Operation is OptionalOperation) { OptionalOperation op = tree.Operation as OptionalOperation; op = op.Clone() as OptionalOperation; List <ObjectFormulaTree> list = new List <ObjectFormulaTree>(); list.Add(tree[0]); for (int i = 1; i < 3; i++) { list.Add(tree[i].Derivation(variableName)); } return(new ObjectFormulaTree(op, list)); } return(null); }
/// <summary> /// Creates formula /// </summary> /// <param name="tree">Operation tree</param> /// <param name="level">Formula level</param> /// <param name="sizes">Sizes of symbols</param> /// <returns>The formula</returns> public MathFormula CreateFormula(ObjectFormulaTree tree, byte level, int[] sizes) { return(OptionalOperation.CreateFormula(this, tree, level, sizes, symbol + "")); }