# ChebCoefficients: ChebCoefficients In gajdosandrej/CharFunToolR: Numerical Computation Cumulative Distribution Function and Probability Density Function from Characteristic Function

 ChebCoefficients R Documentation

## ChebCoefficients

### Description

`ChebCoefficients(values)` converts function values, say values = `f(x)`, evaluated at Chebyshev points of the 2nd kind, say n-dimensional x, to n-dimensional Chebyshev coefficients.

### Usage

``````ChebCoefficients(values)
``````

### Arguments

 `values` function values evaluated at Chebyshev points of the 2nd kind

### Value

`c = ChebCoefficients(values)` returns the n-dimensional vector of coefficients such that ```f(x) = C(1)*T_{0}(x) + C(2)*T_{1}(x)+ ... + C(N)*T_{n-1}(x)``` (where `T_{k}(x)` denotes the k-th 1st-kind Chebyshev polynomial) interpolates the data `[values(1); ... ; values(n)]` at Chebyshev points `x = [x(1); ... ; x(n)]` of the 2nd kind.

If values is an (n x m)-matrix, then `C = ChebCoefficients(values)` returns the (n x m)-matrix of coefficients C.

### Note

Ver.: 15-Nov-2021 17:33:19 (consistent with Matlab CharFunTool v1.3.0, 28-May-2021 14:28:24).

Other Utility Function: `ChebPoints()`, `ChebPolyValues()`, `ChebPoly()`, `ChebValues()`, `GammaLog()`, `GammaMultiLog()`, `GammaMulti()`, `GammaZX()`, `Hypergeom1F1MatApprox()`, `Hypergeom1F1Mat()`, `Hypergeom2F1Mat()`, `Hypergeom2F1()`, `HypergeompFqMat()`, `InterpChebValues()`, `hypergeom1F1()`, `interpBarycentric()`

### Examples

``````## EXAMPLE1 (Chebyshev coefficients of the Sine function on (-pi,pi))
# n      <- 2^5+1
# domain <- c(-pi,pi)
# x      <- ChebPoints(n,domain)
# f      <-list( sin(x[]))
# coeffs <- ChebCoefficients(f)
# print(list(x[], coeffs))
# x      <- seq(-pi,pi,length.out=100)
# pval   <- ChebPolyValues(coeffs,x,domain)
# plotReIm(function(x)
#         pval,x,
# xlab="x",
# ylab="Chebyshev polynomial",
# title="Chebyshev Polynomial Values Specified by its Coefficients")

## EXAMPLE2 (Chebyshev coefficients of the Sine and the Cosine on (-pi,pi))
n      <- 2^5+1
domain <- c(-pi,pi)
x      <- ChebPoints(n,domain)
f      <-list(sin(x[]), cos(x[]))
coeffs <- ChebCoefficients(f)
print(list(x[], coeffs))
x      <- seq(-pi,pi,length.out=100)
pval   <- ChebPolyValues(coeffs,x,domain)
pval1<-list()
for (i in 1:length(pval[1,])) {

pval1[[i]]<-pval[,i]
}
# matplot(x, pval,type="o",col=c("red","green"),lty=c(1,1),
#        xlab="x",
#       ylab="Chebyshev polynomial",
#      main="Chebyshev Polynomial Values Specified by its Coefficients")
plotReIm3( pval1,
x,
title="Chebyshev Polynomial Values Specified by its Coefficients",
xlab = "x",
ylab ="Chebyshev polynomial" )

``````

gajdosandrej/CharFunToolR documentation built on Aug. 22, 2023, 9:58 a.m.