Beispiel #1
0
        public override IFunction derivative()
        {
            IFunction leftSide, rightSide, multipleDderivative;

            leftSide            = new Multiplication(Toleft.derivative(), ToRight);
            rightSide           = new Multiplication(Toleft, ToRight.derivative());
            multipleDderivative = new AddFunction(leftSide, rightSide);
            return(multipleDderivative);
        }
Beispiel #2
0
        public override IFunction derivative()
        {
            IFunction leftSide, rightSide, addDderivative;

            leftSide       = Toleft.derivative();
            rightSide      = ToRight.derivative();
            addDderivative = new AddFunction(leftSide, rightSide);
            return(addDderivative);
        }
Beispiel #3
0
        public override string BinaryTree()
        {
            String temp = "\nnode" + this.Id + " [ label = \"*\" ][shape=polygon,sides=6,peripheries=3,color=lightpink,style=filled]\n";

            temp += "node" + this.Id + " -- node" + Toleft.Id + "[style=dotted,color=purple]\n";
            temp += Toleft.BinaryTree();
            temp += "node" + this.Id + " -- node" + ToRight.Id + "[shape=record,color=purple]\n";
            temp += ToRight.BinaryTree();
            return(temp);
        }
Beispiel #4
0
        public override double Evaluate(double val)
        {
            if (ToRight.Evaluate(val) == 0)
            {
                throw new Exception("you can not devide by zero!");
            }
            double evaluation = Toleft.Evaluate(val) / ToRight.Evaluate(val);

            return(evaluation);
        }
Beispiel #5
0
        public override IFunction derivative()
        {
            IFunction devisionDderivative, leftabove, rightabove, minusAboveDevision, powerDown;

            leftabove           = new Multiplication(Toleft.derivative(), ToRight);
            rightabove          = new Multiplication(Toleft, ToRight.derivative());
            minusAboveDevision  = new MinusFunction(leftabove, rightabove);
            powerDown           = new Power(ToRight, new Numbers(2));
            devisionDderivative = new DevisionFunction(minusAboveDevision, powerDown);
            return(devisionDderivative);
        }
Beispiel #6
0
 public override IFunction Simplify()
 {
     if (ToRight.GetType() == typeof(Numbers))
     {
         if (ToRight.ToInfix() == "0")
         {
             throw new Exception("Can not divide by zero!");
         }
     }
     if (Toleft.GetType() == typeof(Numbers))
     {
         if (Toleft.ToInfix() == "0")
         {
             return(new Numbers(0));
         }
     }
     return(new DevisionFunction(Toleft, ToRight));
 }
Beispiel #7
0
 public override IFunction Simplify()
 {
     if (Toleft.GetType() == typeof(Numbers))
     {
         if (Toleft.ToInfix() == "0")
         {
             return(new Numbers(0));
         }
     }
     if (ToRight.GetType() == typeof(Numbers))
     {
         if (ToRight.ToInfix() == "0")
         {
             return(new Numbers(0));
         }
         return(new Multiplication(Toleft, ToRight));
     }
     else
     {
         return(new Multiplication(Toleft, ToRight));
     }
 }
Beispiel #8
0
        public override string ToPrefix()
        {
            string toprefixvalue = Toleft.ToPrefix() + ToRight.ToPrefix();

            return(toprefixvalue);
        }
Beispiel #9
0
        public override double Evaluate(double val)
        {
            double evaluation = Toleft.Evaluate(val) * ToRight.Evaluate(val);

            return(evaluation);
        }