Group Abstract Group Abstract

Message Boards Message Boards

0
|
4.9K Views
|
3 Replies
|
2 Total Likes
View groups...
Share
Share this post:

[?] Avoid problem with Interpolation function for higher order derivatives?

Posted 6 years ago
POSTED BY: Rui Ma
3 Replies

Rui,

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:

Manipulate[Nx = 2^pow; u0 = 0; uN = 5; du = (uN - u0)/Nx;
 ugrid = du Range[0, Nx];
 C0 = Exp[-(# - Lx/2)^2/2] & /@ ugrid; 
 exact[x] = D[Exp[-(x - Lx/2)^2/2], {x, der}];
 C0Poly = 
  Interpolation[N[Transpose[{ugrid, C0}], 30], 
   InterpolationOrder -> 10];
 exact[x] = D[Exp[-(x - Lx/2)^2/2], {x, der}];
 Plot[{Derivative[der][C0Poly][x], exact[x]}, {x, 0, Lx}, 
  PlotRange -> All, 
  ImageSize -> Large], {{pow, 9, 
   Dynamic["Points: " <> ToString[2^pow]]}, 4, 15, 
  1}, {{der, 9, Dynamic["Deriv: " <> ToString[der]]}, 1, 12, 1}, 
 ContinuousAction -> False, LabelStyle -> "Text"]

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.

Regards,

Neil

POSTED BY: Neil Singer
Posted 6 years ago

Neil,

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.

Best regards, Rui

POSTED BY: Rui Ma

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.

Again, this is just a guess.

POSTED BY: Daniel Lichtblau
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard