Typically you use redundant computations, which don't have to be done from the start. You could calculate intermediate values and check them before proceeding