// V(x + y) = V(x) + V(y)
 protected override Expression VisitSum(Sum A)
 {
     return Sum.New(A.Terms.Select(i => Visit(i)));
 }
Пример #2
0
 protected override Expression VisitSum(Sum A)
 {
     return Sum.New(A.Terms.Select(i => Visit(i)).Where(i => !i.EqualsZero()));
 }
Пример #3
0
 protected override Expression VisitSum(Sum A)
 {
     return EvaluateSum(A.Terms.SelectMany(i => Sum.TermsOf(Visit(i))));
 }
Пример #4
0
        protected override string VisitSum(Sum A)
        {
            int pr = Parser.Precedence(Operator.Add);

            StringBuilder s = new StringBuilder();
            s.Append(Visit(A.Terms.First(), pr));
            foreach (Expression i in A.Terms.Skip(1))
            {
                string si = Visit(i, pr);

                if (si[0] != '-')
                    s.Append("+");
                s.Append(si);
            }
            return s.ToString();
        }
Пример #5
0
 public Expression Solve(Expression x)
 {
     return(Unary.Negate(Sum.New(this.Where(i => !i.Key.Equals(x)).Select(i => Product.New(i.Key, i.Value)))) / this[x]);
 }
Пример #6
0
 // Expression operators.
 public static LazyExpression operator +(LazyExpression L, LazyExpression R)
 {
     return(new LazyExpression(Sum.New(L.value, R.value)));
 }
Пример #7
0
 public static LazyExpression operator -(LazyExpression L, LazyExpression R)
 {
     return(new LazyExpression(Sum.New(L.value, Unary.Negate(R.value))));
 }