# Cache alphanm in nonlinear (legacy) calculations for speedup

Since `alphanm`

is dependent on frequency, `m`

and `n`

, but independent of plane and coordinate powers, it is possible to cache the calculations for reuse.

It produces identical results as before when using the following modified version of `examples/input_files/FlatChamberInputFileNonlinear.txt`

: input.dat

For this input, it achieves a speedup of approx. 5x, from 61s to 13s (100 frequencies, 3rd order terms).

This MR is branched off of MR !18 (merged) for simplicity, to avoid merge conflicts. !18 (merged) is therefore marked as a dependency.

Edited by Eskil Vik