A general method of field calculation for head-medium systems