public static Expression Multiply(params Expression[] terms) { TypeInference type = new TypeInference(terms); List <Expression> factors = type.CastToMaxNumeric() .Where(x => !Elementary.IsConstantOne(x)) .ToList(); if (factors.Exists(Elementary.IsConstantZero)) { return(Zero()); } return(factors.Reduce(Expression.Multiply, One())); }
public static Expression Divide(Expression a, Expression b) { if (Elementary.IsConstantZero(a)) { return(Arithmeric.Zero()); } if (Elementary.IsConstantOne(b)) { return(a); } TypeInference type = new TypeInference(a, b); List <Expression> expressions = type.CastToMaxNumericList(); return(Expression.Divide(expressions[0], expressions[1])); }