Drake
Drake C++ Documentation
ChebyshevPolynomial Class Reference

Detailed Description

Represents the Chebyshev polynomial of the first kind Tₙ(x).

One definition of Chebyshev polynomial of the first kind is Tₙ(cos(θ)) = cos(nθ) It can also be defined recursively as

T₀(x) = 1
T₁(x) = x
Tₙ₊₁(x) = 2xTₙ(x) − Tₙ₋₁(x)

#include <drake/common/symbolic/chebyshev_polynomial.h>

Public Member Functions

 ChebyshevPolynomial (Variable var, int degree)
 Constructs a Chebyshev polynomial Tₙ(x) More...
 
const Variablevar () const
 Getter for the variable. More...
 
int degree () const
 Getter for the degree of the Chebyshev polynomial. More...
 
Polynomial ToPolynomial () const
 Converts this Chebyshev polynomial to a polynomial with monomial basis. More...
 
double Evaluate (double var_val) const
 Evaluates this Chebyshev polynomial at var_val. More...
 
bool operator== (const ChebyshevPolynomial &other) const
 Checks if this and other represent the same Chebyshev polynomial. More...
 
bool operator!= (const ChebyshevPolynomial &other) const
 Checks if this and other do not represent the same Chebyshev polynomial. More...
 
bool operator< (const ChebyshevPolynomial &other) const
 Compare this to another Chebyshev polynomial, returns True if this is regarded as less than the other, otherwise returns false. More...
 
std::vector< std::pair< ChebyshevPolynomial, double > > Differentiate () const
 Computes the differentiation of a Chebyshev polynomial dTₙ(x)/dx = nUₙ₋₁(x) where Uₙ₋₁(x) is a Chebyshev polynomial of the second kind. More...
 
Implements CopyConstructible, CopyAssignable, MoveConstructible, MoveAssignable
 ChebyshevPolynomial (const ChebyshevPolynomial &)=default
 
ChebyshevPolynomialoperator= (const ChebyshevPolynomial &)=default
 
 ChebyshevPolynomial (ChebyshevPolynomial &&)=default
 
ChebyshevPolynomialoperator= (ChebyshevPolynomial &&)=default
 

Friends

template<class HashAlgorithm >
void hash_append (HashAlgorithm &hasher, const ChebyshevPolynomial &item) noexcept
 Implements the hash_append generic hashing concept. More...
 

Constructor & Destructor Documentation

◆ ChebyshevPolynomial() [1/3]

◆ ChebyshevPolynomial() [2/3]

◆ ChebyshevPolynomial() [3/3]

ChebyshevPolynomial ( Variable  var,
int  degree 
)

Constructs a Chebyshev polynomial Tₙ(x)

Parameters
varThe variable x
degreeThe Chebyshev polynomial is of degree n.
Precondition
degree >= 0.

Member Function Documentation

◆ degree()

int degree ( ) const

Getter for the degree of the Chebyshev polynomial.

◆ Differentiate()

std::vector<std::pair<ChebyshevPolynomial, double> > Differentiate ( ) const

Computes the differentiation of a Chebyshev polynomial dTₙ(x)/dx = nUₙ₋₁(x) where Uₙ₋₁(x) is a Chebyshev polynomial of the second kind.

Uₙ₋₁(x) can be written as a summation of Chebyshev polynomials of the first kind with lower degrees.

  • If n is even dTₙ(x)/dx = 2n ∑ⱼ Tⱼ(x), j is odd and j <= n-1
  • If n is odd dTₙ(x)/dx = 2n ∑ⱼ Tⱼ(x) - n, j is even and j <= n-1
  • A special case is that dT₀(x)/dx = 0.
    Return values
    chebyshev_coeff_pairs.sum(chebyshev_coeff_pairs[j].first * chebyshev_coeff_pairs[j].second) is the differentiation dTₙ(x)/dx. If n is even, then chebyshev_coeff_pairs[j] = (T₂ⱼ₋₁(x), 2n). If n is odd, then chebyshev_coeff_pairs[j] = (T₂ⱼ(x), 2n) for j >= 1, and chebyshev_coeff_pairs[0] = (T₀(x), n). For the special case when degree() == 0, we return an empty vector.

◆ Evaluate()

double Evaluate ( double  var_val) const

Evaluates this Chebyshev polynomial at var_val.

◆ operator!=()

bool operator!= ( const ChebyshevPolynomial other) const

Checks if this and other do not represent the same Chebyshev polynomial.

◆ operator<()

bool operator< ( const ChebyshevPolynomial other) const

Compare this to another Chebyshev polynomial, returns True if this is regarded as less than the other, otherwise returns false.

If this.var() < other.var(), return True. If this.var() > other.var(), return False. If this.var() == other.var(), then return this.degree() < other.degree().

A special case is when this.degree() == 0 or other.degree() == 0. In this case the variable doesn't matter, and we return this.degree() < other.degree().

◆ operator=() [1/2]

ChebyshevPolynomial& operator= ( ChebyshevPolynomial &&  )
default

◆ operator=() [2/2]

ChebyshevPolynomial& operator= ( const ChebyshevPolynomial )
default

◆ operator==()

bool operator== ( const ChebyshevPolynomial other) const

Checks if this and other represent the same Chebyshev polynomial.

Two Chebyshev polynomials are equal iff their variable and degree are the same, or they both have degree 0.

Note
T₀(x) = T₀(y) = 1

◆ ToPolynomial()

Polynomial ToPolynomial ( ) const

Converts this Chebyshev polynomial to a polynomial with monomial basis.

◆ var()

const Variable& var ( ) const

Getter for the variable.

Friends And Related Function Documentation

◆ hash_append

void hash_append ( HashAlgorithm &  hasher,
const ChebyshevPolynomial item 
)
friend

Implements the hash_append generic hashing concept.


The documentation for this class was generated from the following file: