# Why 2nd derivative is "squared" to represent wigglyness in GAM?

In David Miller's presentation (here, slide 21), he drew 1st derivative and 2nd derivative of a function. Then he said (slide 22) that grey part can is :

$$\int (\frac{\partial ^{2}f(x)}{\partial x^{2}})^{2}dx$$

My question is: the grey area should not have the "squared" to calculate its area, why not the below form:

$$\int (\frac{\partial ^{2}f(x)}{\partial x^{2}})dx$$

## 1 Answer

Consider one cycle of a sine wave: $$\sin(x)$$ on the interval $$[0,2\pi]$$. We can agree this is "wiggly", right?

The second derivative is $$-\sin(x)$$. Integrate that over $$[0,2\pi]$$ and you get zero "wiggliness".

The second derivative is squared so that concave and convex sections of the curve, which intuitively should both contribute equally to "wiggliness" if they are the same shape, both contribute equally to "wiggliness" if they are the same shape. Note also that the wiggliness is unaffected if the curve is flipped upside down--again, a property that you should like the measure to have.