numerically stable forward, backward, and forward-backward implementations