@TedShifrin So I suppose if $f : M \to \Bbb R$ is a smooth function, by Thom transversality theorem you can make $j^2 f : M \to J^2(M, \Bbb R)$ transverse to the subset $Z \subset J^2(M, \Bbb R)$ consisting of 2-jets where both the formal derivative and the formal 2nd derivative are degenerate. $J^2(M, \Bbb R)$ fibers over $M \times \Bbb R$ with fiber $\Bbb R^n \times \Bbb R^{n(n+1)/2}$ and $Z$, fiberwise, has codimension $n+1$ in there (formal derivative is degenrate iff it's 0, the 2nd formal derivative is degenerate if $\det = 0$).