An Algebraic Quantum Circuit Compression Algorithm for Hamiltonian Simulation