library(Deriv)



  1. Use integration by substitution to solve the integral below.



\[\int{ 4e^{-7x} dx}\]


pull out the coefficient

\(4\int{ e^{-7x} dx}\)



\(u=-7x\)


take the derivative of u


\(\frac{du}{dx}=-7\)


integrate “back”, note e to any exponent changes at a rate equal to itself

\(\int{e^u \ du} = e^u\)


pull out 4 and \(\frac{1}{7}\) under the constant or linearity rule


\[\int{ 4e^{-7x} dx} \ = \frac{-4}{7} e^{-7x} + C\]



2.Biologists are treating a pond contaminated with bacteria. The level of contamination is changing at a rate of \(\frac{dN}{dt} = - \frac{3150}{t^4} -220\) bacteria per cubic centimeter per day, where t is the number of days since treatment began.


Find a function N( t ) to estimate the level of contamination if the level after 1 day was 6530 bacteria per cubic centimeter.


extract out the coefficient, integrate the denominator

\[\int{\frac{-3150}{t^4} -220 } \ dx \ = 3150 \int{\frac{1}{t^4} -220 } \ dx \ = 3150 \int{t^{-4} -220 } \ dx \ = \ 3150*\frac{t^{-3}}{-3} - 200x \ = \ \frac{1050}{x^3}\]

By invoking this function with x=1 we can deduce the value of C


# rate_func<-function(x) { 3150/x^4 - 220 }

f1<-function(x) { return((1050/x^3) - 220*x) }
C<-6530 - f1(1)

print(paste("C = ", C))
## [1] "C =  5700"


Add 5700 to the function and plot …


f2<-function(x) { return((1050/x^3) - 220*x + 5700) }

x<-seq(from=1, to=15)
plot(x,f2(x),type='l', xlab="days", ylab="Contamination", title="Contamination Level")




  1. Find the total area of the red rectangles in the figure below, where the 3. equation of the line is f ( x ) = 2x-9.

Find the area of the region bounded by the graphs of the given equations.

calc_area<-function(x,interval){ return((2*x-9)*interval) }

interval<-1
sum(calc_area(seq(5,8),interval))
## [1] 16


this is is the sum of discrete values…

\[\sum_{x=5}^{x=8} 2x-9\]

apparently its the same when you do it as a continuous distribution

interval<-.001
sum(calc_area(seq(4.5,8.5,by=interval),interval))


integrand<-function(x){ return(2*x-9) }
integrate(integrand, lower = 4.5, upper = 8.5)
## [1] 16.004
## 16 with absolute error < 1.8e-13




  1. Find the area of the region bounded by the graphs of the given equations. \[y=x^2-2x-2\]


\[y = x + 2\]


Set up the functions…


f1<-function(x) { x^2-2*x-2 }
f2<-function(x) { x+2 }

x<-seq(from=-6, to=6)
plot(x,f1(x),type='l')
lines(x,f2(x),type='l')
abline(h=0, col="blue")


The curves intercept at (-1,1) and (4,6) so we need to solve


\[\int_{-1}^4 ( f(x) -g(x) ) \ dx\]


Where f(x) is the “above” curve, in this case its the line so


\[\int_{-1}^4 (x+2) \ dx - \int_{-1}^4 x^2-2x-2 \ dx\]


int1<-integrate(f1, lower = -1, upper = 4)
int2<-integrate(f2, lower = -1, upper = 4)


print(paste("The area is ", int2$value-int1$value))
## [1] "The area is  20.8333333333333"




  1. A beauty supply store expects to sell 110 flat irons during the next year. It costs $3.75 to store one flat iron for one year. There is a fixed cost of $8.25 for each order. Find the lot size and the number of orders per year that will minimize inventory costs.

Im not clear whats being asked because usually an optimization problem involves opposite factors of different degrees. If i create a function of x where x is inventory bought minus expected sales of 110 per year, and square it, I have a somewhat realistic parabola …

f1<-function(x) { (x-110)^2 -8.25*x + 1100    }

f1_prime<-Deriv(f1)
minimum_inventory<-uniroot(f1_prime, lower=0, upper=50, extendInt="yes")$root

title<-paste("Minimum Inventory Cost = ", minimum_inventory)

x<-seq(from=100, to=150)
plot(x,f1(x),type='l', ylim = c(0,500), title=title)

print(title)
## [1] "Minimum Inventory Cost =  114.125"




  1. Use integration by parts to solve the integral below.


\[\int \ ln(9x) \ x^6 \ dx\]




\(u=ln(x)\) \(du=\frac{1}{x}\) \(dv=x^6 \ dx\) \(v=\frac{x^7}{7}=\frac{1}{7}x^7\)


plug in


\[\int{u \ dv} = uv \ - \ \int{v} \ du\]

uv is …


\[\frac{ln(9x) x^7}{7}\]


\(\int{v} \ du\) is …


\[\frac{1}{7}\int{x^7} \ = \frac{x^7}{49}\]


Multiply uv by \(\frac{7}{7}\) to get the final answer


\[\frac{x^7 (7ln(9x)-1)}{49} +C\]




  1. Determine whether f(x) is a probability density function on the interval \([1,e^6]\) .

If not, determine the value of the definite integral


\[f(x) \ = \ \frac{1}{6x}\]


f1<-function(x) { 1/(6*x) }

e<-exp(1)


integrate(f1, lower = 1, upper = e^6)
## 1 with absolute error < 9.3e-05


It could be a probability distribution within that interval.


x<-seq(from=1, to=e^6)
plot(x,f1(x),type='l')
abline(h=0, col="blue")

But only on that interval. Values less than 1 wont work.


x<-seq(from=-200, to=e^6, by=.1)
plot(x,f1(x),type='l', ylim = c(-2,2))
abline(h=0, col="blue")