:<math> f''(x) = f(x+2) - 2 f(x+1) + f(x)</math>
I then used f'(x) to determine the layer index from which the variance explained was monotonic (i.e., there was no change in sign in f'(x) in higher layer indices), found the layer index <math>i</math> at which <math>varexp_i = min(varexp)</math>for some city-year, and marked <math>i+1</math> as the elbow layerfor that city-year.
====Fixing the layer index====