So the trick is to do the computation forwards, but take care to only use reversible operations, store the result outside of the auxiliary "full" memory and then run the computation backwards, reversing all instructions and thus undoing their effect on the auxiliary space. Which is called catalytic, because it wouldn't be able to do the computation in the amount of clean space it has, but can do it by temporarily mut…
Alternatively, Ian Mertz's survey might be a bit more accessible than the original catalytic paper: https://iuuk.mff.cuni.cz/~iwmertz/papers/m23.reusing_space.p...