#23 p231 maximize profit given revenue, r(x)=8*sqrt(x) and cost, c(x)=2*x^2
r(x)=8*sqrt(x)
c(x)=2*x^2
p(x)=r(x)-c(x)
rp(x)=diff(r(x),x)
cp(x)=diff(c(x),x)
pp(X)=diff(p(x),x)
show(r(x))
show(c(x))
show(p(x))
show(rp(x))
show(cp(x))
show(pp(x))
show(solve(pp(x)==0,x)[2])
show(p(1))
p1=plot(p(x),.1,4,color='red')
p2=plot(pp(x),.1,4,color='green')
#since p(x)=r(x)-c(x), p'(x)=r'(x)-c'(x)
#so p(x) has a min or a max when r'(x)=c'(x)!
#max occurs at x=1 (thousand widgets)
#and max = p(1) = 6 (mega bux)
p1+p2