private Node GenerateMaclaurinSeriesPolynomial(double x, int order) { if (order == 0) { return(this); } if (order == 1) { return(new PlusSign(new MultiplicationSign(ReturnDerivative(x), new VariableNode()), this)); } VariableNode variableNode = new VariableNode(); NaturalNumberNode orderNode = new NaturalNumberNode(order); CaretSign caretSign = new CaretSign(variableNode, orderNode); Node f0 = ReturnDerivative(x); for (int i = 1; i < order; i++) { f0 = f0.ReturnDerivative(x); } MultiplicationSign multiplicationSign = new MultiplicationSign(caretSign, new RationalNumberNode(f0.Calculate(0))); FactorialFunction factorialFunction = new FactorialFunction(orderNode); DivisionSign divisionSign = new DivisionSign(multiplicationSign, factorialFunction); return(new PlusSign(divisionSign, ReturnMaclaurinSeriesPolynomial(x, order - 1))); }
public double ReturnMaclaurinSeries(double x, int order) { if (order == 0) { return(Calculate(0)); } if (order == 1) { return(ReturnDerivative(x).Calculate(0) * x + Calculate(0)); } VariableNode variableNode = new VariableNode(); NaturalNumberNode orderNode = new NaturalNumberNode(order); CaretSign caretSign = new CaretSign(variableNode, orderNode); Node f0 = ReturnDerivative(x); for (int i = 1; i < order; i++) { f0 = f0.ReturnDerivative(x); } MultiplicationSign multiplicationSign = new MultiplicationSign(caretSign, new RationalNumberNode(f0.Calculate(0))); FactorialFunction factorialFunction = new FactorialFunction(orderNode); DivisionSign divisionSign = new DivisionSign(multiplicationSign, factorialFunction); return(divisionSign.Calculate(x) + ReturnMaclaurinSeries(x, order - 1)); }
public override Node ReturnDerivative(double x) { SineFunction sineNode = new SineFunction(child.Copy()); CosineFunction cosineNode = new CosineFunction(child.Copy()); DivisionSign division = new DivisionSign(sineNode, cosineNode); return(division.ReturnDerivative(x)); }
public override Node ReturnDerivative(double x) { if (Calculate(x) > 0) { Node childDerivative = child.ReturnDerivative(x); DivisionSign divisionSignA = new DivisionSign(childDerivative, child.Copy()); return(divisionSignA); } return(new RationalNumberNode(Double.NaN)); }
public override Node ReturnDerivative(double x) { MultiplicationSign multiplicationSignA = new MultiplicationSign(leftNode.ReturnDerivative(x), rightNode.Copy()); MultiplicationSign multiplicationSignB = new MultiplicationSign(leftNode.Copy(), rightNode.ReturnDerivative(x)); MinusSign minusSign = new MinusSign(multiplicationSignA, multiplicationSignB); NaturalNumberNode naturalNumberNode = new NaturalNumberNode(2); CaretSign caretSign = new CaretSign(rightNode.Copy(), naturalNumberNode); DivisionSign division = new DivisionSign(minusSign, caretSign); return(division); }
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)); }