first implementation of worksheet3. Residual calculation not working!