I'm not understanding how to set up these equations in terms of profit, revenue, and cost.

I know P=R-C. That all seems sort of elementary, but when I impliment it I'm messing up somewhere as I'm getting different answers as to what is written in the back of the book.

Here is the problem given.

Maximum Profit: A commodity has a demand function modeled by and a total cost function of

a.) What price yields a maximum profit?

b.) When the profit is maximized, what is the average cost per unit?

Here is how I'm attempting to work the material out

The equation should be set up in terms of Profit=Revenue-Cost and the maximum profit can be taken from the derivative of that equation.

So... revenue is gained from units sold multiplied by the price and the cost equation was given above, so just plugging them in I set them up like this.

into

into

working out the - and finding the first derivative this is where I went from here

which would become

which is

The back of the book says I should have gotten $80 and I got . What did I do wrong and how do I go from there to find the average cost per unit when maximized? Thanks in advance