Finding the domain of compositions of functions