|
|
|
|
|
by Majromax
621 days ago
|
|
> Math.sin(x)/x (the sinc function) for 7 terms over [-3,3] gives coefficients c0...c6 that are all NaNs. Is this a bug? That wouldn't exactly be a bug. The code is undoubtedly calculating the Chebyshev coefficients by evaluating the function on something like x_j = (xmin) + (xmax - xmin)/2(1 + cos(pi[0..j-1]/(j-1)). If one of those grid points happens to be exactly 0, it will try to evaluate Math.sin(0)/0, giving the NaN. Another workaround is to have a slightly asymmetric range, such as [-3,+3.0000001] |
|