testing a new formula for the residual... maybe the last one was wrong
improved speed by using cdivision=True and removing the try: except: block from the intensively looped region