示例#1
0
 public override AlgebraExpression Substitute(SymbolExpression variable, AlgebraExpression replacement)
 {
     return(this
            .WithExpression(this.Expression.Substitute(variable, replacement))
            .WithTo(this.To.Substitute(variable, replacement))
            );
 }
示例#2
0
        public IntegralExpression(AlgebraExpression expression, SymbolExpression respectTo, AlgebraExpression from, AlgebraExpression to)
        {
            if (expression == null)
            {
                throw new ArgumentNullException(nameof(expression));
            }

            if (respectTo == null)
            {
                throw new ArgumentNullException(nameof(respectTo));
            }

            if (from != null && to == null)
            {
                throw new ArgumentNullException(nameof(to));
            }

            if (from == null && to != null)
            {
                throw new ArgumentNullException(nameof(from));
            }

            this.Expression = expression;
            this.RespectTo  = respectTo;
            this.From       = from;
            this.To         = to;
        }
示例#3
0
 public override AlgebraExpression Substitute(SymbolExpression variable, AlgebraExpression replacement)
 {
     return(this
            .WithBase(this.Base.Substitute(variable, replacement))
            .WithExponent(this.Exponent.Substitute(variable, replacement))
            );
 }
示例#4
0
 public static SumExpressionList Polynomial(SymbolExpression variable, IReadOnlyList <AlgebraExpression> coefficients)
 {
     return(Sum(
                coefficients
                .Select((c, i) => Multiply(c, Exponentiate(variable, coefficients.Count - i)))
                .ToImmutableList()
                ));
 }
 public override AlgebraExpression Substitute(SymbolExpression variable, AlgebraExpression replacement)
 {
     return(this.WithTerms(
                this.Terms
                .Select(t => t == variable ? replacement : variable)
                .Select(t => t.Substitute(variable, replacement))
                .ToImmutableList()
                ));
 }
        public DifferentiationExpression(AlgebraExpression expression, SymbolExpression respectTo)
        {
            if (expression == null)
            {
                throw new ArgumentNullException(nameof(expression));
            }

            if (respectTo == null)
            {
                throw new ArgumentNullException(nameof(respectTo));
            }

            this.Expression = expression;
            this.RespectTo  = respectTo;
        }
示例#7
0
        public LimitExpression(AlgebraExpression expression, SymbolExpression respectTo, AlgebraExpression to)
        {
            if (expression == null)
            {
                throw new ArgumentNullException(nameof(expression));
            }

            if (respectTo == null)
            {
                throw new ArgumentNullException(nameof(respectTo));
            }

            if (to == null)
            {
                throw new ArgumentNullException(nameof(to));
            }

            this.Expression = expression;
            this.RespectTo  = respectTo;
            this.To         = to;
        }
 public override AlgebraExpression Substitute(SymbolExpression variable, AlgebraExpression replacement)
 {
     return(this);
 }
 public DifferentiationExpression WithRespectTo(SymbolExpression newVariable)
 {
     return(Differentiate(this.Expression, newVariable));
 }
 public static DifferentiationExpression Differentiate(AlgebraExpression expression, SymbolExpression respectTo)
 {
     return(new DifferentiationExpression(expression, respectTo));
 }
        public static AlgebraExpression TotalDerivative(this AlgebraExpression function, IReadOnlyCollection <SymbolExpression> parameters, SymbolExpression respectTo)
        {
            if (!parameters.Contains(respectTo))
            {
                throw new ArgumentException($"Parameter '{nameof(respectTo)}' must be one of the variables provided in parameter '{nameof(parameters)}'.", nameof(respectTo));
            }

            return(Sum(
                       parameters
                       .Select(p => function.PartialDerivative(p) * p.Differentiate(respectTo))
                       .ToImmutableList()
                       ));
        }
示例#12
0
 public IntegralExpression(AlgebraExpression expression, SymbolExpression respectTo)
     : this(expression, respectTo, null, null)
 {
 }
示例#13
0
 /// <summary>
 /// Replaces every occurrences of <paramref name="subject"/> to <paramref name="replacement"/>.
 /// </summary>
 /// <param name="variable"></param>
 /// <param name="replacement"></param>
 /// <returns></returns>
 public abstract AlgebraExpression Substitute(SymbolExpression variable, AlgebraExpression replacement);
示例#14
0
 public static SumExpressionList Polynomial(SymbolExpression variable, params AlgebraExpression[] coefficients)
 {
     return(Polynomial(variable, coefficients as IReadOnlyList <AlgebraExpression>));
 }
示例#15
0
 public LimitExpression WithRespectTo(SymbolExpression newVariable)
 {
     return(Limit(this.Expression, newVariable, this.To));
 }
示例#16
0
 public static IntegralExpression Integrate(this AlgebraExpression expression, SymbolExpression respectTo, AlgebraExpression from, AlgebraExpression to)
 {
     return(ExpressionFactory.Integrate(expression, respectTo, from, to));
 }
示例#17
0
 public static LimitExpression Limit(AlgebraExpression expression, SymbolExpression respectTo, AlgebraExpression to)
 {
     return(new LimitExpression(expression, respectTo, to));
 }
示例#18
0
 public IntegralExpression WithRespectTo(SymbolExpression newVariable)
 {
     return(Integrate(this.Expression, newVariable, this.From, this.To));
 }
示例#19
0
 public static bool IsConstant(this AlgebraExpression expression, SymbolExpression respectTo)
 {
     return(!expression.DependsUpon(respectTo));
 }
 public static DifferentiationExpression Differentiate(this AlgebraExpression expression, SymbolExpression respectTo)
 {
     return(ExpressionFactory.Differentiate(expression, respectTo));
 }
示例#21
0
 public static bool DependsUpon(this AlgebraExpression expression, SymbolExpression respectTo)
 {
     return(expression.DescendantsAndSelf().Contains(respectTo));
 }
 public static DifferentiationExpression PartialDerivative(this AlgebraExpression expression, SymbolExpression respectTo)
 {
     return(Differentiate(expression, respectTo));
 }
 public override AlgebraExpression Substitute(SymbolExpression variable, AlgebraExpression replacement)
 {
     return(this.WithArguments(this.Arguments.Select(a => a.Substitute(variable, replacement)).ToImmutableList()));
 }
示例#24
0
 public static IntegralExpression Integrate(AlgebraExpression expression, SymbolExpression respectTo, AlgebraExpression from, AlgebraExpression to)
 {
     return(new IntegralExpression(expression, respectTo, from, to));
 }