# How to find the second derivative of this function according to the limit definition?

I want to find the second derivative of function $$f(x)=-(x-1)^{2}+(x-1)^{3} \sin \left(\frac{1}{(x-1)^{2}}\right)$$ at x = 1 according to the definition of limit:

f[x_] := -(x - 1)^2 + (x - 1)^3 Sin[1/(x - 1)^2]
Limit[((f[h + k + x] - f[k + x])/h - (f[h + x] - f[x])/h)/k /.
x -> 1, {h -> 0, k -> 0}]

Limit[((f[h + k + x] - f[k + x])/h - (f[h + x] - f[x])/h)/k, {h -> 0,
k -> 0}]
Limit[((f[h + k + x] - f[k + x])/h - (f[h + x] - f[x])/h)/
k, {h, k} -> {0, 0}]


But the result of the above code is very strange, I want to know what the correct method should be?

• The definition of f is perhaps incomplete. It is undefined at 1. And so neither the first nor the second derivative is defined at 1. Perhaps f = 0? Actually it is better to use Piecewise, in which case the first limit will give the correct answer. Aug 27, 2020 at 23:54
• @Michael E2 Did you read my answer before having commented the question? Aug 28, 2020 at 7:32
• You changed the definition of the function without asking the OP what was meant, and you don't comment that OP's code for the limit was correct. My main point was about the limit, for which the observation and question about f was a necessary foundation. How to find f'' with the limit is also the principal question, which you do not answer. The answer is, the iterated limit works fine and gives the correct result in both cases, whether one "fixes" the definition of f or not. I think the question is the result of a simple mistake that caused the OP to be confused by the error messages. Aug 28, 2020 at 12:54

This is a variation on the theme of Example 2 from Ch.3 in B. Gelbaum and J. Olmsted, Counterexamples in Analysis, where a differentiable function having the discontinuous derivative is constructed.

First, you should to redefine the function at $$x=1$$ by

f[x_] := Piecewise[{{-(x - 1)^2 + (x - 1)^3 Sin[1/(x - 1)^2],
x != 1}, {0, x == 1}}]


Second, you need not two gains $$h$$ and $$k$$ to find the second derivative at $$x=1$$, only $$h$$ is enough (see Wiki)

Limit[(f[1 + h] - 2*f + f[1 - h])/h^2, h -> 0]
(*-2*)


The second derivative is discontinuous at $$x=1$$ as

Plot[f''[x], {x, 0, 2}]


Addition. Unfortunately, nobody notices an inaccuracy in my answer so I must indicate it on my own. The limit

Limit[(f[1 + h] - 2*f + f[1 - h])/h^2, h -> 0]


equals f'' only if that second derivative exists. However, in the case under consideration the derivative f'[x] is discontinuous at x==1 as the results of

MaxLimit[f'[x], x -> 1]
(*2*)


and

MinLimit[f'[x], x -> 1]
(*-2*)


prove. Therefore, f'[x] does not have the derivative at x==1, being discontinuous at that point.

• The discontinuity of the second derivative at $x=1$ can be estalished analitically through MaxLimit[f''[x], x -> 1] which results in Infinity. Aug 27, 2020 at 12:18