public static Expression operator -(Expression lhs, Expression rhs) { return(new Expression(SortedOperations.Merge(lhs.Terms, rhs.Terms.Select(term => - term), MergeTerm).Where(term => term.Coefficient != 0).ToArray())); }
public static Expression Sum(IEnumerable <Expression> expressions) { return(new Expression(SortedOperations.MergeMany(expressions.Select(expr => expr.Terms), MergeTerm).Where(term => term.Coefficient != 0).ToArray())); }
public static Term operator /(Term lhs, Term rhs) { return(new Term(lhs.Coefficient / rhs.Coefficient, SortedOperations.Merge(lhs.Variables, rhs.Variables.Select(var => ~var), MergeVariable, _baseComparer).Where(var => var.Exponent != 0).ToArray())); }