I have the following problem.
We have a set of discrete points ($x_i$,$y_i$), defined for $0 \leq x_i \leq r$, where $r$ is an arbitrary value. For values of $0 \leq x \leq r$, the y value is obtained from polynomial interpolation over 6 points, three with $x_i < x$ and three with $x_i > x$.
For $x > r$, y must go to zero. The current technique used is to extrapolate with a polynomial matched on the last 6 points of the set, plus 3 points forced to zero. This leads to weird wiggling due to Runge's phenomenon.
One idea I have is to perform least squares on a negative exponential, which is guaranteed to go to numerical zero. However, the problem occurs at the point where we switch from interpolation to extrapolation, because we want to guarantee the first derivative to be continuous in $r$. Splines (at least the ones I know) don't satisfy these constraints, and a simple extrapolation to negative exponential will produce a non-continuous first derivative.
Do you have any hints on how to tackle this problem ?
Edit: this is an example of the data (I plot two curves, but they are the same, I just had this plot around).
I need to go to zero by extending the curve beyond point 16 so that it goes to zero only at +infinity (like an negative exponential), with the constraint that in point 16 it must be smooth. I removed the need for the second derivative to have the same sign. This is clearly not possible here.
Note that the points can be considered either exact or not. The problem is that for $x < r$ we assume the points are exact and when $x = x_i$ you should get $y_i$. However, when $x > r$, the points are not considered exact anymore for the extrapolation, thus the need for a least square fitting.