The quotient rule states that,

#d/dx(u/v)=(u'v-uv')/v^2#

Here, #u=(3x+1)^2#, #v=(sqrt(x)+1)^2#

So, we have to differentiate #u# using the chain rule, which says that

#d/dx(f(g(x))=color(blue)(f'(g(x)))*color(red)(g'(x))#

Here, the function is #(3x+1)^2#, the inside derivative is #3#, so

#d/dx((3x+1)^2)=color(blue)(2(3x+1))*color(red)(3)=6(3x+1)#

With the same method, we can differentiate #v#, the function is #(sqrt(x)+1)^2#, inside derivative is #1/(2sqrt(x))#.

So,

#d/dx((sqrt(x)+1)^2)=color(blue)(2(sqrt(x)+1)*color(red)(1/(2sqrt(x)))=color(black)((sqrt(x)+1)/sqrt(x))#

Now, we put those back into the quotient rule,

#d/dx((3x+1)^2/(sqrt(x)+1)^2)=(6(3x+1)(sqrt(x)+1)^2-(3x+1)^2((sqrt(x)+1))/sqrt(x))/(sqrt(x)+1)^4#

Simplifying gives us,

#d/dx((3x+1)^2/(sqrt(x)+1)^2)=(9x^2sqrt(x)+27x^2+18xsqrt(x)+6x+5sqrt(x)-1)/(sqrt(x)(sqrt(x)+1)^4)#