This is the laplacian operator (in 1D, just the second derivative, or curvature). The sharper the crest, the more negative; the sharper the trough, the more positive. If you change the value there, by that much, the effect is averaging (and the discretized form is literally averaging).
You've been doing calculus the whole time. There's a difference between knowing the path, and walking the path.
You just set each pixel’s brightness to be the average brightness of the immediately adjacent pixels. Calculate from bottom to top.
Add a few “hot” pixels moving back and forth along the bottom and boom, instant fire.
Looks very cool for a tiny amount of code and no calculus. :)