Question

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

Was it helpful?

Solution

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.

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top