matrix rules from algebra