Create function for writing expressions in a factored form