calculates resultant