Using R, provide the solution for any exercise in either Chapter 4 or Chapter 7 of the calculus textbook. If you are unsure of your solution, post your concerns.

library(mosaic)
## 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

Chapter 4.3

Find the maximum product of two numbers (not necessarily integers) that have a sum of 100.

Answer: x=50, y=50, Area= 2500

After solving below equation, we will solve for a \(y=100-x\) Now we substitute this into the product \[ \mathrm{P}(\mathrm{x})=x(100-x) \] We now have an equation of one variable which only makes sense for values between 0 and 100 , otherwise, we end up with negative number. Now to find the critical points we need to find the derivative of \(P(x)\) : \[ \begin{aligned} &\mathrm{P}(\mathrm{x})=x(100-x) \\ &\mathrm{P}(\mathrm{x})=100 x-x^{2} \\ &\mathrm{P}^{\prime}(\mathrm{x})=100-2 x 0=100-2 x \\ &2 x=100 \\ &x=50 \end{aligned} \] Below is an example of using \(R\) functions to perform caclulations for us: We can also find the derivative using the expression() and \(D()\) functions as follows:

#defines a variable and assigns a function to is using the expression() function
p = expression(100*x-x**2) 

#finds the derivative of the expression assigned to the variable p
D(p,'x')
## 100 - 2 * x

Deriv() function

p = expression(100*x-x**2) 
#finds the derivative of function p
deriv(p,'x')
## expression({
##     .value <- 100 * x - x^2
##     .grad <- array(0, c(length(.value), 1L), list(NULL, c("x")))
##     .grad[, "x"] <- 100 - 2 * x
##     attr(.value, "gradient") <- .grad
##     .value
## })

Findzeroes() function from Mosaic

#finds the zeros to the equation defined in the function
findZeros(100 - 2*x ~ x, xlim=c(0,100))
##    x
## 1 50
#finds the zeros to the equation defined in the function in complex notation
polyroot(c(100,-2))
## [1] 50+0i

Based on the output, our x value is 50, substituting back into the y=100−x function, we get our y = 50 , Area = 2500.