Calculating analytical matrix functions