I added the tag "difference-equations" because this question generated when I was exploring finite difference method.
But I still look forward to a better solution: maybe a little greed?
I'd like to point out that, though I chose "$f(a)$ and $0$" to generate list in the example above for the sake of simplicity, this question is more general, the generated list may be formed by "$f(a)$ and $g(a)$", or even by "$f(a1,a2)$ and $g(a1,a2)$". Still, I appreciated and will appreciate those answers that focus on special cases since the "$f(a)$ and $0$" cases are simple but also common.
I added the tag "difference-equations" because this question generated when exploring finite difference method (FDM). I believe it's a inevitable issue when programming FDM.
Here are two existed post that can be optimized or answered with the outcome of this discussion:
How to discretize a nonlinear PDE fast?
How do I solve a PDE with a strange boundary condition?