Calculus with R

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



\(u=-7x\hspace{.3cm} du=-7dx\)
\(\huge\int_{}^{}4e^{-7x}dx\)
\(\huge\int_{}^{}-\frac{4}{7}e^u\hspace{.1cm}du\)
\(\huge\int_{}^{}-\frac{4}{7}e^u\hspace{.1cm}du\)
\(\huge-\frac{4}{7}\int_{}^{}e^u du\)
\(\huge-\frac{4}{7}e^u + C\)
\(\huge-\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.



\(\huge\frac{dN}{dt}=-\frac{3150}{t^4}-220\)
\(\huge3150\int_{}^{}\frac{1}{t^4}dt-220\int_{}^{}1dt\)
\(\huge3150\int_{}^{}-\frac{1}{3t^3}-220t\)
\(\bigg\frac{1050}{t^3}-220t+C\)
\(\huge N(1)= \frac{1050}{t^3}-220t+ C\)
\(\huge 6530= \frac{1050}{1^3}-220(1)+ C\)
\(\huge 6530= 1050-220 + C\)
\(\huge 5700= C\)
\(\huge N(t)= \frac{1050}{t^3}-220t+5700\)


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

f <- function(x) 2*x-9
paste0('The area is ',integrate(f,4.5,8.5)$value)
## [1] "The area is 16"

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

y = \(x^2-2x-2\), y=x+2

Bounds: \(x^2 -2x-2=x+2\) \(x^2 -3x-4=0\) \((x-4)(x+1)=0\) \(x=\{4,-1\}\)

y_one <- function(x) x+2
y_two <- function(x) x^2 - 2*x -2

int_one <- integrate(y_one,-1,4)
int_two <- integrate(y_two,-1,4)
total_area <- int_one$value - int_two$value
## [1] "The area of the region bounded by interval [-1,4] is: 20.833"



5. 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.



assumption: 2 flat irons stored on average x=flat iron orders c = cost function \(storage costs = 3.75 * x/2 =1.875x\)  \(order costs = 8.25 *110/x = 907.5/x\)
\(cost function = 1.875x + 907.5/x\)
\(c'(x) = 1.875 - \frac{907.5}{x^2}\)
\(c'(x) = 1.875x^2=907.5\)
\(x^2=\frac{907.5}{1.875}\)
\(x=\sqrt(\frac{907.5}{1.875})\)
\(x=22\)
\(c = 1.875*22+907.5/22 = \$82.5\)
\(lot size = 110/x = 5\)


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



\(\huge \int ln(9x)*x^6dx\)

\(d(uv)=udv+vdu\)
\(\int d(uv)=uv=\int u\hspace{.1cm} dv + \int v \hspace{.1cm}du\)
\(\int u\hspace{.1cm} dv=uv-\int v \hspace{.1cm}du\)
\(u=ln(9x)\)
\(\frac{dv}{dx}=x^6\)
\(du=\frac{9}{9x}dx=\frac{1}{x}dx\)
\(dv=x^6dx\)
\(v=\frac{1}{7}x^7\)
\(ln(9x)\frac{1}{7}x^7-\int \frac{1}{7}x^7\frac{1}{x}dx\)
\(ln(9x)\frac{x^7}{7}-\frac{x^7}{49}-C\)
\(\frac{x^7(7ln(9x)-1)}{49}+C\)

7. 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}\)

f_sev <- function(x) 1/(6*x)
is_pdf <- integrate(f_sev,1,exp(6))
## [1] "Since the integral equals 1 from 1 to e^6 it is a probability density function."