Example #1
0
        public override BaseExpression Simplify()
        {
            var newLHS = Lhs.Simplify();
            var newRHS = Rhs.Simplify();

            // If both are constants
            if (newLHS is Real constLhs && newRHS is Real constRhs)
            {
                return(new Real(constLhs.Value + constRhs.Value));
            }
            // If one of them is zero, omit it
            if (newLHS is Real zeroLhs && zeroLhs.Value == 0)
            {
                return(newRHS);
            }