views:

128

answers:

2

Hi community,

I have a function that sometimes is non-differentiable at a point. When I now use a spline (Bezierspline in degrafa) for interpolation the interpolation at this point does not work as expected (at this point my function has a kink). Now when interpolating with a spline it draws some kind of loop around this point. I think this happens because the spline needs the derivatives of the functions which is not unique at this point.

Is that right? What would you advise me to do in this case?

Thanks in advance

Sebastian

+1  A: 

That sounds right. It's been a while since I've looked at splines, but I'm pretty sure if the function is not continuous, your spline should also be discontinuous at the same points. Although I have seen interpolations that give an approximate curve at such a point... I'll check my text-books if no one else comes up with a better answer.

But a loop is a pretty good attempt. kudos to your function.

Cogsy
+1  A: 

You can't calculate the gradient of a "kink" (as you so eloquently put it). If you really need a gradient at such a point (x), I'd just average the gradient at (x-d) and (x+d) where d is a small enough delta. It's as mathematically valid as any other single answer you're likely to get.

For example, the function:

f(x) = |x|

will produce:

\   |   /
 \  |  /
  \ | /
   \|/
----+----

where there is no gradient at the origin (0,0). However, averaging the gradients at -0.0001 (gradient = -1) and +0.0001 (gradient = +1) will give you a gradient of zero (flat line).

This should give a half-decent answer for other equations that produce non-symmetrical gradients at (x-d) and (x+d) as well.

What I would do, since it's licensed under MIT, is to modify the source to allow an option for the Bezierspline to use that +/- delta method to calculate gradients at the non-continuous points. Maybe even push back the source changes to the developers if you think it's a worthwhile addition.

paxdiablo
yes sorry for that I did not know a good word for that. This would be a possibility for sure but first I have to find these points {x}. Maybe I should switch to a linear interpolation as my functions are quite smooth.
Xelluloid