Example #1
0
 public ProductExpressionList Divide(AlgebraExpression expression)
 {
     return(expression is ProductExpressionList
         ? ExpressionFactory.Product(this, ExpressionFactory.Reciprocal(expression))
         : ExpressionFactory.Divide(this, expression)
            );
 }
Example #2
0
 public ProductExpressionList Multiply(AlgebraExpression expression)
 {
     return(expression is ProductExpressionList
         ? ExpressionFactory.Product(this.Terms.Concat((expression as ProductExpressionList).Terms).ToImmutableList())
         : ExpressionFactory.Multiply(this, expression)
            );
 }
        public AlgebraExpression Simplify(DifferentiationExpression expression, CancellationToken cancellationToken)
        {
            if (expression.Expression is ProductExpressionList product)
            {
                return(Sum(
                           product.Terms
                           .Select(t =>
                                   ExpressionFactory.Product(
                                       new[] { t.Differentiate(expression.RespectTo) }
                                       .Concat(product.Terms.Except(new[] { t }))
                                       .ToImmutableList()
                                       )
                                   )
                           .ToImmutableList()
                           ));
            }

            return(expression);
        }
Example #4
0
 public ProductExpressionList WithTerms(IImmutableList <AlgebraExpression> newTerms)
 {
     return(ExpressionFactory.Product(newTerms));
 }