ENH: Extended chebinterpolate to interpolate a multidimensional function #20529
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently there are no functions in chebyshev.py that do N-dimensional fitting for N>1
This submission is a attempt to fill the above mentioned gap and complements the efforts in #14151.
The multidimensional interpolation method implemented here uses the 1D Discrete Cosine Transform (DCT) instead of the vandermonde method. This is a reimplementation of the chebfitfunc function found in #6071. The accuracy of the new interpolation method is better than the old chebinterpolate function especially for polynomials of high degrees as shown
in the figures below.
The figures show the interpolation error for various degrees when interpolating the exponential function from -1 to 1 using DCT (blue) compared to the Vandermonde method (orange) used in the previous version of chebinterpolate.
Most notable the accuracy of the Vandermonde method deteriorates as the degree increaces beyond the value of 32 while DCT keeps machine precision accuracy in this case (i.e. error less than 3,0e-16). The run times for each method is given in the legend and show that the Vandermonde method is slightly faster for degrees less or equal to 63 while DCT is slightly faster otherwise.
Also added domain as input to chebinterpolate in order to interpolate the function over any input domain.
Also replaced all references to the missing chebfromfunction with chebinterpolate.