SYMPY_USE_CACHE=debug results in errors

Rewrite lambda as a function.  This avoids a runtime error (i.e. return value of cached and not cached function differ)  with

SYMPY_USE_CACHE=debug py.test -x sympy/integrals/tests/test_trigonometry.py

In order for #7464 to move forward, errors resulting from comparing cached/not cached functions need to be fixed.