This is exercise base on P=50-0.5q, C(q)=100+10q+0.5q^2.

## Registered S3 method overwritten by 'mosaic':
##   method                           from   
##   fortify.SpatialPolygonsDataFrame ggplot2
## 
## The 'mosaic' package masks several functions from core packages in order to add 
## additional features.  The original behavior of these functions should not be affected by this.
## 
## Attaching package: 'mosaic'
## The following objects are masked from 'package:dplyr':
## 
##     count, do, tally
## The following object is masked from 'package:Matrix':
## 
##     mean
## The following object is masked from 'package:ggplot2':
## 
##     stat
## The following objects are masked from 'package:stats':
## 
##     binom.test, cor, cor.test, cov, fivenum, IQR, median, prop.test,
##     quantile, sd, t.test, var
## The following objects are masked from 'package:base':
## 
##     max, mean, min, prod, range, sample, sum
## 
## Attaching package: 'mosaicCalc'
## The following object is masked from 'package:stats':
## 
##     D
## function (q) 
## 50 - 0.5 * q
## function (q) 
## 100 + 10 * q + 0.5 * q^2
## function (q) 
## (50 - 0.5 * q) * q
## function (q) 
## -100 + 40 * q - q^2
## Warning: Removed 1 row containing missing values or values outside the scale range
## (`geom_text()`).

## function (q) 
## q + 10
## function (q) 
## 50 - q
## function (q) 
## 2 * (20 - q)
## function (q) 
## q + 10
## function (q) 
## 50 - q
## function (q) 
## 40 - 2 * q

## function (q) 
## 2 * (20 - q)
##    q
## 1 20
## [1] 300
##         q
## 1  2.6795
## 2 37.3205