Determining average cost, revenue equations and profit maximization