# Interpolation and points of non-differentiability

I have some data, which if expressed by some elementary functions, would contain a non-differentiable point. I would like to be able to use something like interpolate to convert the data into a function and then differentiate it but somehow still preserve the non-differentiability property at that point.

MWE

list = Table[{j, Max[5, j]}, {j, 0, 15, 1}]

{{0, 5}, {1, 5}, {2, 5}, {3, 5}, {4, 5}, {5, 5}, {6, 6}, {7, 7}, {8,
8}, {9, 9}, {10, 10}, {11, 11}, {12, 12}, {13, 13}, {14, 14}, {15,
15}}


My data comes from a continuous function which is not differentiable at $x=5$.

fint = Interpolation[list]

dfint[x_] = D[fint[x], x]

Plot[dfint[x], {x, 0, 15}, AxesOrigin -> {0, -1}]


The Derivative looks like this:

Update 12:38 AM May 22:

lista = DeleteCases[list, a_ /; a[[1]] >= 6]
listb = DeleteCases[list, a_ /; a[[1]] <= 4]

{{0, 5}, {1, 5}, {2, 5}, {3, 5}, {4, 5}, {5, 5}}

{{5, 5}, {6, 6}, {7, 7}, {8, 8}, {9, 9}, {10, 10}, {11, 11}, {12,
12}, {13, 13}, {14, 14}, {15, 15}}

ga = Interpolation[lista]
gb = Interpolation[listb]

dga[x_] = D[ga[x], x]
dgb[x_] = D[gb[x], x]

g[x_] = Piecewise[{{ga[x], x <= 5}, {gb[x], x > 5}}]

dg[x_] = Piecewise[{{dga[x], x < 5}, {dgb[x], x > 5}}]


Doing this

Plot[dg[x], {x, 0, 15}, AxesOrigin -> {0, -1}]


gives

However

dg[5]

0


I guess I need to get this to be indeterminate.

-
Just do dg[x_] = D[g[x], x] and then dg[5] automatically becomes indeterminate... – Rahul May 22 '13 at 4:44
You could use Piecewise[]'s default value; set it to Indeterminate instead of 0. – J. M. May 22 '13 at 4:45
@RahulNarain and J.M. great thanks! – Amatya May 22 '13 at 5:09
Look also at InterpolationOrder. – Jonathan Shock May 22 '13 at 7:08
@RahulNarain oh, yes, I wasn't focused enough – Kuba Mar 28 '14 at 2:57

Just do dg[x_] = D[g[x], x] and then dg[5] automatically becomes indeterminate.