Leveraging Symbolic Algebra Systems to Simulate Contact Dynamics in Rigid Body Systems