What is the best way to let mathematica memoize built-in function like e.g.
One possibility would be for sure:
sphericalHarmonicY[l_,m_,th_,ph_]:= sphericalHarmonicY[l,m,th,ph]=SphericalHarmonicY[l, m, th, ph]
But is there some function that works like:
And I can still use the original definition and Mathematica will store the values in the memory and access already calculated values later on?