The center of mass of a one-dimensional object that extends from a position x = 0 to a position x = x2
is given by <x> = {0x2 xρ(x)dx} / {0x2 ρ(x)dx}
where ρ(x) is the linear density of the object at a point x. Here ρ(x) = ax + b, so
<x> = {0x2 x(ax + b)dx} / {0x2 (ax + b)dx} = {0x2 (ax2 + bx)dx} / {0x2 (ax + b)dx}
Recalling that the integral of a polynomial is undu = un+1 / (n+1),
<x> = { ax3 / 3 + bx2/2 } / {ax2/2 + bx}
This expression must be evaluated at the two limits, viz. x = 0 and x = x2.
But all of the terms on the right vanish at x = 0 because they all contain x or a power thereof.
Therefore all of the terms on the right only have the x2 components to them:
<x> = {ax23 / 3 + bx22 / 2 } / { ax22 / 2 + bx2 }
We can divide through by x2 and multiply numerator and denominator by 6 to simplify this:
<x> = { 2ax22 + 3bx2 } / { 3(ax2 + 2b) }
<x> = (x2 / 3) (2ax2 + 3b) / (ax2 + 2b)
and since the problem gives you the values of a, b, and x2, the rest is just plugging in numbers.
Note that if you happened to have a situation
where the density was constant over the length of the object, i.e. if a = 0, then
<x> = (x2 / 3) (2*0x2 + 3b) / (0*x2 + 2b) = (x2 / 3) ( 3b / 2b) = x2 / 2,
which is what you would expect. This gives you more confidence that this formula is correct.