Hey james121515.

In short, are you trying to find derivatives or maxima/minima for functions where derivatives don't exist?

One suggestion I have is if you fit the function to one that is continuous and differentiable by projecting it to say an orthogonal fourier polynomial or orthogonal function basis.

You can find out more about this by looking at fourier analysis.

By choosing the right kinds of functions, you can generate a similar function that preserves derivative information at the turning points.