matrix functions revised and corrected