First, remember that any time you're looking for a marginal function in an economics context, you want the first order derivative of that function.
Then remember that profit is revenue minus cost: P(q) = R(q) - C(q)
Recall the difference rule, where the derivative of the difference of two functions equals the difference between those functions' corresponding derivatives:
P'(q) = R'(q) - C'(q)
Or to phrase it in a way that econ and business majors can understand, marginal profit is marginal revenue minus marginal cost:
MP(q) = MR(q) - MC(q)
(Also note that the difference rule is just a special case of the sum rule, where the second addend is negative.)
Since the revenue and cost functions are simple polynomials, the power rule (lower the power of x by 1 and multiply by the previous power), sum rule, and constant rule should suffice for evaluating the marginal profit function.
I'll write out the power rule for clarity, just as a reminder:
If f(x) = a*xn, where a is constant and n is any nonzero integer, then f'(x) = n*a*xn-1.
Since the degree of the sum (or difference) of the polynomials is the higher degree between them, the profit function should be quadratic, since the revenue function is quadratic and the cost function is linear.
P(q) = a*q2 + b*q + c (where a,b,c are constants)
That means the marginal profit function is going to be a linear function.
MP(q) = 2a*q + b
Note again that the sum/difference rules imply that the order in which you subtract and differentiate is irrelevant. So you could just as easily differentiate the revenue and cost functions separately, and then subtract the derivatives to get the marginal profit function.