add update residual function

1 job for algorithm in 4 minutes and 46 seconds (queued for 2 seconds)