public int Compare(SymbolicExpression x, SymbolicExpression y) { var(ux, uy) = (ExpressionSimplifier.UnwrapFactors(x), ExpressionSimplifier.UnwrapFactors(y)); int result = Comparer <byte> .Default.Compare(ux.Expression.GetSortOrder(), uy.Expression.GetSortOrder()); if (result == 0) { result = CompareUnwrapped(ux.Expression, uy.Expression); } if (result == 0) { result = Comparer <long> .Default.Compare(ux.Factor, uy.Factor); } return(result); }
public static SymbolicExpression Ln(SymbolicExpression x) => ExpressionSimplifier.TrySimplifyLn(x) ?? new UnaryOperationExpression(UnaryOperator.Ln, x);
public static SymbolicExpression Cos(SymbolicExpression x) => ExpressionSimplifier.TrySimplifyCos(x) ?? new UnaryOperationExpression(UnaryOperator.Cos, x);
public static SymbolicExpression Root(SymbolicExpression x, SymbolicExpression y) => ExpressionSimplifier.TrySimplifyRoot(x, y) ?? new BinaryOperationExpression(BinaryOperator.Root, x, y);
public static SymbolicExpression Pow(SymbolicExpression x, SymbolicExpression y) => ExpressionSimplifier.TrySimplifyPower(x, y) ?? new BinaryOperationExpression(BinaryOperator.Power, x, y);
public static SymbolicExpression Divide(SymbolicExpression a, SymbolicExpression b) => ExpressionSimplifier.TrySimplifyDivision(a, b) ?? new BinaryOperationExpression(BinaryOperator.Division, a, b);
public static SymbolicExpression Multiply(ImmutableArray <SymbolicExpression> operands) => ExpressionSimplifier.TrySimplifyMultiplication(operands) ?? new VariadicOperationExpression(VariadicOperator.Multiplication, operands);
public static SymbolicExpression Multiply(SymbolicExpression a, SymbolicExpression b) => ExpressionSimplifier.TrySimplifyMultiplication(a, b) ?? new BinaryOperationExpression(BinaryOperator.Multiplication, a, b);
public static SymbolicExpression Subtract(SymbolicExpression a, SymbolicExpression b) => ExpressionSimplifier.TrySimplifySubtraction(a, b) ?? new BinaryOperationExpression(BinaryOperator.Subtraction, a, b);
public static SymbolicExpression Add(ImmutableArray <SymbolicExpression> operands) => ExpressionSimplifier.TrySimplifyAddition(operands) ?? new VariadicOperationExpression(VariadicOperator.Addition, operands);
public static SymbolicExpression Add(SymbolicExpression a, SymbolicExpression b) => ExpressionSimplifier.TrySimplifyAddition(a, b) ?? new BinaryOperationExpression(BinaryOperator.Addition, a, b);
public static SymbolicExpression Negate(SymbolicExpression e) => ExpressionSimplifier.TrySimplifyNegation(e) ?? new UnaryOperationExpression(UnaryOperator.Minus, e);