Ashley Hay's cool finish earned Dundee a hard-fought derby win over Dundee United at Tannadice in the Scottish Premiership.