public override IBaseMathOperator Derivate()
        {
            if (A is ConstantMathOperator && B is ConstantMathOperator)
            {
                return(new ConstantMathOperator(0));
            }
            if (!(A is ConstantMathOperator || B is ConstantMathOperator))
            {
                var left = new MultiplyMathOperator();
                left.Instantiate(new [] { A.Derivate(), B });

                var right = new MultiplyMathOperator();
                right.Instantiate(new [] { B.Derivate(), A });

                var add = new AddMathOperator();
                add.Instantiate(new IBaseMathOperator[] { left, right });

                return(add);
            }
            var ADir = A is ConstantMathOperator ? A : A.Derivate();
            var BDir = B is ConstantMathOperator ? B : B.Derivate();

            var multi = new MultiplyMathOperator();

            multi.Instantiate(new [] { ADir, BDir });

            return(multi);
        }
Esempio n. 2
0
        public override IBaseMathOperator Derivate()
        {
            if (IsConstant())
            {
                return(new ConstantMathOperator(0));
            }

            var add = new AddMathOperator
            {
                A = A.Derivate(),
                B = B.Derivate()
            };

            return(add);
        }