Exercise 1

Use integration by substitution to solve the integral below. ó õ 4e -7x d

In order to solve the integral using integration by substitution. We will need to take the following steps:

 1. Identify the substitution variable i.e., (u = -7x) and then compute the differential of the substitution variable as followed: (du = -7, dx).

2. Rewrite the integral in terms of the new variable:

[ \int 4e^u \left(-\frac{1}{7}\right) , du ]

  1. Integrate the simplified expression:

[ -\frac{4}{7} \int e^u , du = -\frac{4}{7} e^u + C ]

4. Substitute back to find the final result;

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

Given the integral: [ \int 4e^{-7x} , dx ]

Therefore, the solution to the integral is:

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

Let’s solve it in R:

# Define the function for the antiderivative
antiderivative <- function(x) {
  -4/7 * exp(-7*x) + C  # Replace C with the constant of integration if needed
}

# Print the antiderivative
cat("The antiderivative of 4e^(-7x) with respect to x is: -4/7 * exp(-7x) + C\n")
## The antiderivative of 4e^(-7x) with respect to x is: -4/7 * exp(-7x) + C

Difference in results depending on the approach.

It seems important to use the same upper limit of integration for consistency in results as proven by the discrepancies in the results below:

First approach:

Directly integrating the function 4e −7x with respect to x. This approach is straightforward and aligns more closely with the original problem statement.

# Define the constant of integration
C <- 0  # Example value of the constant C, replace with the actual value if given

# Define the bounds of integration
a <- 0  # Lower limit
b <- 1  # Upper limit

# Calculate the definite integral using the antiderivative
definite_integral <- function(x) {
  -4/7 * exp(-7*x) + C
}

integral_value <- definite_integral(b) - definite_integral(a)

# Print the value of the definite integral
cat("The value of the definite integral is:", integral_value, "\n")
## The value of the definite integral is: 0.5709075

Second approach: This approach integrates the function 4eu with respect to u after a substitution.

# Define the integrand and its antiderivative
f <- function(u) {
  4 * exp(u)
}

# Define the antiderivative of the integrand
F <- function(u) {
  4/(-7) * exp(u)
}

# Define the limits of integration in terms of u
a <- 0  # Lower limit
b <- 1  # Upper limit

# Perform the substitution
I <- F(b) - F(a)

# Print the result
cat("The value of the integral is:", I, "\n")
## The value of the integral is: -0.9818753

Third approach: changing and setting the limit of integration at 2 instead of 1

# Define the integrand and its antiderivative
f <- function(u) {
  4 * exp(u)
}

# Define the antiderivative of the integrand
F <- function(u) {
  4/(-7) * exp(u)
}

# Define the limits of integration in terms of u
a <- 0  # Lower limit
b <- 2  # Upper limit

# Perform the substitution
I <- F(b) - F(a)

# Print the result
cat("The value of the integral is:", I, "\n")
## The value of the integral is: -3.650889

Exercise 2

Biologists are treating a pond contaminated with bacteria. The level of contamination is changing at a rate of dN dt =  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.

SOLUTION:

we can integrate the given rate of change of contamination over time to find the function N(t)N(t). Then, we can use the initial condition provided to determine the constant of integration as followed:

  1. Integrate the rate of change of contamination, dNdtdtdN​, with respect to tt to find N(t)N(t).

Integrate dNdt=−3150t4−220dtdN​=−3150t4−220 with respect to tt to find N(t)N(t). N(t)=∫(−3150t4−220) dtN(t)=∫(−3150t4−220)dt

  1. Use the initial condition N(1)=6530N(1)=6530 to determine the constant of integration.

    N(1)=6530N(1)=6530. N(1)=∫11(−3150t4−220) dt=6530N(1)=∫11​(−3150t4−220)dt=6530

  2. Define the function N(t)N(t) in R using the determined constant of integration.

Let’s implement this in R

# Define the rate of change of contamination function
dN_dt <- function(t) {
  -3150 * t^4 - 220
}

# Integrate the rate of change function to find N(t)
N <- function(t) {
  integral <- integrate(dN_dt, lower = 1, upper = t)$value
  return(integral + 6530)  # Add the constant of integration determined from the initial condition
}

# Test the function with a specific value of t
t <- 2  # Example value of t
contamination_level <- N(t)
cat("The estimated contamination level after", t, "days is:", contamination_level, "bacteria per cubic centimeter.\n")
## The estimated contamination level after 2 days is: -13220 bacteria per cubic centimeter.

Exercise 3

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

SOLUTION:

Finding the signed area between the functions

# Define the function representing the line f(x) = 2x - 9
f <- function(x) {
  2*x - 9
}

# Define the range of x-values over which to compute the area
x_min <- 0  # Lower limit of x
x_max <- 5  # Upper limit of x
delta_x <- 0.01  # Width of each rectangle

# Initialize the total area
total_area <- 0

# Compute the area of each rectangle and sum them up
x <- x_min
while (x < x_max) {
  height <- f(x)  # Height of the rectangle
  width <- delta_x  # Width of the rectangle
  area <- height * width  # Area of the rectangle
  total_area <- total_area + area  # Add the area to the total
  x <- x + delta_x  # Move to the next x-value
}

# Print the total area of the red rectangles
cat("The total area of the red rectangles is:", total_area, "\n")
## The total area of the red rectangles is: -20.04

Finding the absolute difference between the functions:

# Define the functions
f1 <- function(x) x^2 - 2*x - 2
f2 <- function(x) x + 2

# Calculate the definite integral
area <- integrate(function(x) abs(f1(x) - f2(x)), lower = -1, upper = 4)

# Print the result
cat("The area of the region bounded by the graphs is approximately:", area$value, "square units.\n")
## The area of the region bounded by the graphs is approximately: 20.83333 square units.

Exercise 4

Find the area of the region bounded by the graphs of the given equations. y = x 2  2x  2, y = x + 2 Enter your answer below

Given equations:

1.     (y = x^2 - 2x - 2)

2.     (y = x + 2)

We need to find the intersection points to determine the limits of integration. Setting the two equations equal to each other:

[ x^2 - 2x - 2 = x + 2 ]

Solving for (x): [ x^2 - 3x - 4 = 0 ] Factoring: ((x - 4)(x + 1) = 0)

So, the intersection points are (x_1 = -1) and (x_2 = 4).

Now let’s calculate the area in R:

First approach: Using Absolute Difference and Integration

# Define the functions
f1 <- function(x) x^2 - 2*x - 2
f2 <- function(x) x + 2

# Calculate the definite integral
area <- integrate(function(x) abs(f1(x) - f2(x)), lower = -1, upper = 4)

# Print the result
cat("The area of the region bounded by the graphs is approximately:", area$value, "square units.\n")
## The area of the region bounded by the graphs is approximately: 20.83333 square units.

2nd approach: Using Integration with Absolute Difference

# Define the functions
f1 <- function(x) x^2 - 2*x - 2
f2 <- function(x) x + 2

# Visualize the functions
curve(f1, xlim = c(-5, 5), ylim = c(-5, 5), col = "blue", main = "Graphs of the functions", xlab = "x", ylab = "y")
curve(f2, col = "red", add = TRUE)

# Add a legend
legend("topright", legend = c("y = x^2 - 2x - 2", "y = x + 2"), col = c("blue", "red"), lty = 1)

# Adjust the interval to contain a sign change
intersection_interval <- c(-3, 3)

# Find the intersection points
intersection_points <- uniroot(function(x) f1(x) - f2(x), interval = intersection_interval)$root

# Define the absolute difference function
abs_diff <- function(x) abs(f1(x) - f2(x))

# Calculate the area by integrating the absolute difference function
area <- integrate(abs_diff, lower = min(intersection_points), upper = max(intersection_points))$value

# Print the area
cat("The area of the region bounded by the graphs is approximately:", area, "square units.\n")
## The area of the region bounded by the graphs is approximately: 0 square units.

Exercise 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

SOLUTION:

To minimize the total annual inventory cost, we need to minimize the sum of ordering costs and holding costs. This means finding the optimal lot size that minimizes the total annual inventory cost.

We can use optimization techniques in R to find the optimal lot size and the number of orders per year that minimize inventory costs.

# Given parameters
total_demand <- 110
fixed_order_cost <- 8.25
storage_cost <- 3.75

# Calculate the Economic Order Quantity (EOQ) using the formula
EOQ <- sqrt((2 * total_demand * fixed_order_cost) / storage_cost)

# Calculate the optimal lot size (rounded to the nearest integer)
optimal_lot_size <- round(EOQ)

# Calculate the number of orders per year
orders_per_year <- total_demand / optimal_lot_size

# Print the results
cat("Optimal lot size (EOQ):", optimal_lot_size, "\n")
## Optimal lot size (EOQ): 22
cat("Number of orders per year:", orders_per_year, "\n")
## Number of orders per year: 5