carl  24.04
Computer ARithmetic Library
TaylorExpansion.h
Go to the documentation of this file.
1 /*
2  * File: TaylorExpansion.h
3  * Author: Tobias Winkler
4  *
5  * Created on 20. März 2015, 14:44
6  */
7 
8 
9 
10 #pragma once
11 #include "../MultivariatePolynomial.h"
13 
14 
15 namespace carl{
16 
17 template<typename Integer>
19 
22 
23  public:
24 
25  /* for a given polynomial p(x_1,...,x_n) calculate the coefficient of (x_v - a)^k in
26  * the <x_v - a>-adic representation of p(x_1,...,x_n).
27  *
28  * This is equivalent to calculating the "taylor series expansion"
29  * of p about x_v = a, according to GCL92 (Chap. 6, Multivariate Taylor Series Representation)
30  */
32  Polynomial& p,
33  Variable::Arg x_v,
34  FiniteInt a,
35  std::size_t k) {
36 
37  assert(p.has(x_v));
38  // the expansion finishes when the total degree of p in x_v is reached
39  if(k > p.degree(x_v)) {
40  return Polynomial(0);
41  }
42  Polynomial value = Polynomial(a);
44  // error term and it's initialization
45  Polynomial e;
46  e = p - substitute(p,x_v, value);
47  // curr coeff being calculated
48  // when the calculation terminates this will contatin the result
49  Polynomial u;
50  u = Polynomial(0);
51  // now we iterate: u_k = phi_I[(e_(k-1) - u_(k-1)*(x_v - a)^(k-1)) / (x_v - a)^k],
52  // where phi_I[...] denotes the substitution of x_v by a.
53  Polynomial temp;
54  for(unsigned i = 1; i <= k; i++) {
55  e = e - u * ideal.pow(i-1);
56  temp = e / ideal.pow(i);
57  u = substitute(temp,x_v, value);
58  }
59  return u;
60  }
61 };
62 
63 } // namespace carl
carl is the main namespace for the library.
Coeff substitute(const Monomial &m, const std::map< Variable, Coeff > &substitutions)
Applies the given substitutions to a monomial.
Definition: Substitution.h:19
A Variable represents an algebraic variable that can be used throughout carl.
Definition: Variable.h:85
Galois Field numbers, i.e.
Definition: GFNumber.h:21
The general-purpose multivariate polynomial class.
std::size_t degree(Variable::Arg var) const
Calculates the degree of this polynomial with respect to the given variable.
GFNumber< Integer > FiniteInt
static Polynomial ideal_adic_coeff(Polynomial &p, Variable::Arg x_v, FiniteInt a, std::size_t k)
MultivariatePolynomial< FiniteInt > Polynomial
Represents a single term, that is a numeric coefficient and a monomial.
Definition: Term.h:23