I have a function C_0(x)=e^{-(x-2.5)^2/2.0} which is differentiable to infinite order. I want to approximate the function with Interpolation such that it is smooth until 10th derivative. Here is the code I use
Nx = 512; u0 = 0.0; uN = 5.0; du = (uN - u0)/Nx;
ugrid = du Range[0, Nx];
C0 = Exp[-(# - Lx/2)^2/2] & /@ ugrid;
C0Poly = Interpolation[Transpose[{ugrid, C0}], InterpolationOrder -> 10]
However, when I drew the derivatives, it looks smooth only up to 6th order. Here’s how the 7th derivative looks like
The problem is that Derivative is a noisy operation. I improved things by making the numbers use infinite precision and converted them to 30 digits of precision before interpolation. Try Experimenting with this:
It will show you that the number of points matters and actually fewer points will be smoother. For some reason (which I have not yet figured out) the derivative is better if you use a power of two in the number of points. The number of intervals must interact with the method of interpolation. I hope this helps.
Thank you so much! This helps a lot. Though I didn’t get it why fewer points give smoother interpolation, 256 points seem to work properly for my purpose.
I will venture a guess that the more points, the greater the likelihood that the degree ten (or so) local polynomial interpolants have spikes in small regions. This can worsen the noisiness noted by @NeilSinger.