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?

  • 1
    $\begingroup$ 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[1] = 0? Actually it is better to use Piecewise, in which case the first limit will give the correct answer. $\endgroup$
    – Michael E2
    Aug 27, 2020 at 23:54
  • $\begingroup$ @Michael E2 Did you read my answer before having commented the question? $\endgroup$
    – user64494
    Aug 28, 2020 at 7:32
  • $\begingroup$ 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''[1] 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. $\endgroup$
    – Michael E2
    Aug 28, 2020 at 12:54

1 Answer 1


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[1] + f[1 - h])/h^2, h -> 0]

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

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

enter image description here shows.

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[1] + f[1 - h])/h^2, h -> 0]

equals f''[1] 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]


MinLimit[f'[x], x -> 1]

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

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.