Beispiel #1
0
 public override Node ReturnDerivative(double x)
 {
     if (leftNode is NumberNode && rightNode is NumberNode)
     {
         return(new NaturalNumberNode(0));
     }
     else if (leftNode is VariableNode && (rightNode is NaturalNumberNode || rightNode is RationalNumberNode))
     {
         RationalNumberNode rationalNumberNodeA = new RationalNumberNode(rightNode.Calculate(x));
         RationalNumberNode rationalNumberNodeB = new RationalNumberNode(rightNode.Calculate(x) - 1);
         CaretSign          caretSign           = new CaretSign(leftNode.Copy(), rationalNumberNodeB);
         MultiplicationSign multiplicationSign  = new MultiplicationSign(rationalNumberNodeA, caretSign);
         return(multiplicationSign);
     }
     else if (leftNode is NumberNode)
     {
         LogarithmFunction  logarithmFunction   = new LogarithmFunction(leftNode.Copy());
         CaretSign          caretSign           = new CaretSign(leftNode.Copy(), rightNode.Copy());
         MultiplicationSign multiplicationSignA = new MultiplicationSign(logarithmFunction, caretSign);
         MultiplicationSign multiplicationSignB = new MultiplicationSign(multiplicationSignA, caretSign.rightNode.ReturnDerivative(x));
         return(multiplicationSignB);
     }
     else
     {
         MinusSign          minusSign           = new MinusSign(rightNode.Copy(), new NaturalNumberNode(1));
         CaretSign          caretSign           = new CaretSign(leftNode.Copy(), minusSign);
         MultiplicationSign multiplicationSignA = new MultiplicationSign(rightNode.Copy(), caretSign);
         MultiplicationSign multiplicationSignB = new MultiplicationSign(multiplicationSignA, leftNode.ReturnDerivative(x));
         return(multiplicationSignB);
     }
 }
Beispiel #2
0
        public double ReturnNewtonMaclaurinSeries(double x, int order)
        {
            if (order == 0)
            {
                return(Calculate(0));
            }
            if (order == 1)
            {
                return(ReturnNewtonDerivative(0) * x + Calculate(0));
            }
            VariableNode       variableNode       = new VariableNode();
            NaturalNumberNode  orderNode          = new NaturalNumberNode(order);
            CaretSign          caretSign          = new CaretSign(variableNode, orderNode);
            RationalNumberNode f0                 = new RationalNumberNode(CalculatePolynomialDerivative(0, order));
            MultiplicationSign multiplicationSign = new MultiplicationSign(caretSign, f0);
            FactorialFunction  factorialFunction  = new FactorialFunction(orderNode);
            DivisionSign       divisionSign       = new DivisionSign(multiplicationSign, factorialFunction);

            return(divisionSign.Calculate(x) + ReturnNewtonMaclaurinSeries(x, order - 1));
        }