Lesson 3 of 18

Second Derivative

The Second Derivative

The second derivative f(x)f''(x) is the derivative of f(x)f'(x) — the rate of change of the slope.

Geometric Meaning

  • f(x)>0f''(x) > 0: curve is concave up (holds water, like a bowl)
  • f(x)<0f''(x) < 0: curve is concave down (spills water, like a hill)
  • f(x)=0f''(x) = 0: possible inflection point (concavity changes)

Numerical Formula

The second derivative can be approximated directly from ff without computing ff' first:

f(x)f(x+h)2f(x)+f(xh)h2f''(x) \approx \frac{f(x+h) - 2f(x) + f(x-h)}{h^2}

Derivation: expand f(x+h)f(x+h) and f(xh)f(x-h) using Taylor series:

f(x+h)=f(x)+hf(x)+h22f(x)+O(h3)f(x+h) = f(x) + h f'(x) + \frac{h^2}{2} f''(x) + O(h^3)

f(xh)=f(x)hf(x)+h22f(x)+O(h3)f(x-h) = f(x) - h f'(x) + \frac{h^2}{2} f''(x) + O(h^3)

Add them: f(x+h)+f(xh)=2f(x)+h2f(x)f(x+h) + f(x-h) = 2f(x) + h^2 f''(x), so:

f(x)=f(x+h)2f(x)+f(xh)h2f''(x) = \frac{f(x+h) - 2f(x) + f(x-h)}{h^2}

Inflection Points

At an inflection point, f(c)=0f''(c) = 0 and the sign of ff'' changes. Example: f(x)=x3f(x) = x^3 has an inflection at x=0x = 0.

Second Derivative Test

For a critical point cc where f(c)=0f'(c) = 0:

  • f(c)>0f''(c) > 0 → local minimum
  • f(c)<0f''(c) < 0 → local maximum
  • f(c)=0f''(c) = 0 → inconclusive

Your Task

Implement double second_derivative(double (*f)(double), double x, double h).

TCC compiler loading...
Loading...
Click "Run" to execute your code.