public override Operand Differentiate() { // (f(x))^b where b is a natural number even. // The general power rule but combined with the // chain rule. b * (f(x))^(b - 1) * f'(x) // b Operand power = RightSuccessor.Copy(); // b - 1 Integer newPower = new Integer(Convert.ToDouble(power.Data) - 1); // f(x)^(b - 1) Power onePowerLess = new Power(); onePowerLess.LeftSuccessor = LeftSuccessor.Copy(); onePowerLess.RightSuccessor = newPower; // f' Operand derivativeOfF = LeftSuccessor.Differentiate(); // b * f(x)^(b - 1) Multiplication intermediaryResult = new Multiplication(); intermediaryResult.LeftSuccessor = power; intermediaryResult.RightSuccessor = onePowerLess; // (b * f(x)^(b - 1)) * f' Multiplication derivative = new Multiplication(); derivative.LeftSuccessor = intermediaryResult; derivative.RightSuccessor = derivativeOfF; return(derivative); }
public override Operand Copy() { Multiplication copy = new Multiplication(); copy.LeftSuccessor = LeftSuccessor.Copy(); copy.RightSuccessor = RightSuccessor.Copy(); return(copy); }
public override Operand Copy() { Power copy = new Power(); copy.LeftSuccessor = LeftSuccessor.Copy(); copy.RightSuccessor = RightSuccessor.Copy(); return(copy); }
public override Operand Copy() { Addition copy = new Addition(); copy.LeftSuccessor = LeftSuccessor.Copy(); copy.RightSuccessor = RightSuccessor.Copy(); return(copy); }
public override Proposition Copy() { Nand copy = new Nand(); copy.LeftSuccessor = LeftSuccessor.Copy(); copy.RightSuccessor = RightSuccessor.Copy(); return(copy); }
public override Proposition Copy() { BiImplication copy = new BiImplication(); copy.LeftSuccessor = LeftSuccessor.Copy(); copy.RightSuccessor = RightSuccessor.Copy(); return(copy); }
public override Proposition Copy() { Conjunction copy = new Conjunction(); copy.LeftSuccessor = LeftSuccessor.Copy(); copy.RightSuccessor = RightSuccessor.Copy(); return(copy); }
/// <summary> /// Applies the product rule to the sub trees. /// (f * g)' = f * g' + f' * g /// /// The method differentiates the appropriate sub trees and /// eventually returns a single Operand object (in this case /// an addition operator object) holding both an original /// expression sub tree as well as a differentiated sub tree. /// </summary> /// <returns> /// An operator object, representing the applied product rule. /// </returns> public override Operand Differentiate() { // Create and assign fg' Multiplication newLeftExpression = new Multiplication(); newLeftExpression.LeftSuccessor = LeftSuccessor.Copy(); newLeftExpression.RightSuccessor = RightSuccessor.Differentiate(); // Create and assign f'g Multiplication newRightExpression = new Multiplication(); newRightExpression.LeftSuccessor = LeftSuccessor.Differentiate(); newRightExpression.RightSuccessor = RightSuccessor.Copy(); // Create and assign fg' + f'g Addition derivative = new Addition(); derivative.LeftSuccessor = newLeftExpression; derivative.RightSuccessor = newRightExpression; return(derivative); }