Load libraries.

library(glue)

Question 1:

Find the equation of the regression line for the given points. Round any final values to the nearest hundredth, if necessary.

( 5.6, 8.8 ), ( 6.3, 12.4 ), ( 7, 14.8 ), ( 7.7, 18.2 ), ( 8.4, 20.8 )

Answer: y = 4.26x - 14.8

x <- c(5.6, 6.3, 7, 7.7, 8.4)
y <- c(8.8, 12.4, 14.8, 18.2, 20.8)

new_lm <- lm(y ~ x)

slope <- round(coef(new_lm)[2], 2)
intercept <- coef(new_lm)[1]

glue('y = {slope}x + {intercept}')
## y = 4.26x + -14.8

Question 2:

Find all local maxima, local minima, and saddle points for the function given below. Write your answer(s) in the form of (x, y, z ). Separate multiple points with a comma.

\(f (x, y ) = 24x - 6xy^2 - 8y^3\)

  1. Find the partial derivatives.

\(f_{x}(x,y) = 24 - 6y^2\)

\(f_{y}(x,y) = -12xy - 24y^2\)

  1. Set these derivatives equal to 0 and solve.

\(24 - 6y^2 = 0\)

y = 2, y = -2

For y = 2 \(-12xy - 24y^2 = -12x(2) - 24(2)^2 = -24x - 96 = 0\)

x = -4

For y = -2 \(-12xy - 24y^2 = -12x(-2) - 24(-2)^2 = 24x - 96 = 0\)

x = 4

So . . . solutions are (-4,2) or (4,-2)

  1. Plot the function to see which of these points is a minimum, maximum, or saddle point.
# Define your multivariate function f(x, y)
function1 <- function(x, y) {
  return((24 * x) - (6 * x * (y**2)) - (8 * (y**3)))
}

# Generate grid of x and y values
x <- seq(-5, 5, length.out = 100)
y <- seq(-5, 5, length.out = 100)
z <- outer(x, y, function1)

# Plot the function
contour(x, y, z, main = "Contour Plot of f(x, y)")

  1. Determine the results and find z.

Based on the graphs above, points (-4,2) and (4,-2) appear to be saddle points, and the function does not contain any relative maxima or minima.

To find z, just plug in the values of x and y.

Answer: (-4,2,-64) and (4,-2,64) are saddle points

(24 * -4) - (6*(-4)*(4)) - (8*2*2*2)
## [1] -64
(24 * 4) - (6*(4)*(4)) - (8*-2*-2*-2)
## [1] 64

Question 3:

A grocery store sells two brands of a product, the “house” brand and a “name” brand. The manager estimates that if she sells the “house” brand for x dollars and the “name” brand for y dollars, she will be able to sell 81 - 21x + 17y units of the “house” brand and 40 + 11x - 23y units of the “name” brand.

Step 1. Find the revenue function R ( x, y ).

Revenue = Price x Quantity

R(x,y) = house price * (81 - 21x + 17y) + name price * (40 + 11x - 23y)

\(R(x, y) = 81x - 21x^2 + 17xy + 40y + 11xy - 23y^2\)

Step 2. What is the revenue if she sells the “house” brand for $2.30 and the “name” brand for $4.10?

\(R(2.30, 4.10) = (81 * 2.30) - (21 * (2.30)^2) + (17 * 2.30 * 4.10) + (40 * 4.10) + (11 * 2.30 * 4.10) - (23 * (4.10)^2)\)

= 116.62

Answer: $116.62

Question 4:

A company has a plant in Los Angeles and a plant in Denver. The firm is committed to produce a total of 96 units of a product each week. The total weekly cost is given by

\(C(x, y) = \frac {1}{6}x^2 + \frac{1}{6}y^2 + 7x + 25y + 700\)

where x is the number of units produced in Los Angeles and y is the number of units produced in Denver. How many units should be produced in each plant to minimize the total weekly cost?

This question is asking for the maximum (or maxima if more than one maximum exists). To find this, the same process will be used as question 2, but I have to keep in mind that x + y = 96. This means the function can be rewritten as a function of just x or y.

\(C(x) = \frac{1}{6}x^2 + \frac{1}{6}(96 - x)^2 + 7x + 25(96 - x) + 700\)

\(C(x) = \frac{1}{6}x^2 + \frac{1}{6}(9216 - 192x + x^2) + 7x + 2400 - 25x + 700\)

\(C(x) = \frac{1}{6}x^2 + 1536 - 32x + \frac{1}{6}x^2 + 7x + 2400 - 25x + 700\)

\(C(x) = \frac{1}{3}x^2 - 50x + 4636\)

  1. Find the derivative.

\(C'(x) = \frac{2}{3}x - 50\)

  1. Set this derivative equal to 0 and solve.

    \(\frac{2}{3}x - 50 = 0\)

    x = 75

  2. This should be the minimum because of the question. I will determine y and then plug them in to find the cost.

    Based on the results from below, values less than and greater than (75, 21) will result in a higher cost.

x <- 75
y <- 96 - x

(x^2 / 6) + (y^2 / 6) + (7 * x) + (25 * y) + 700
## [1] 2761
x <- 60
y <- 96 - x

(x^2 / 6) + (y^2 / 6) + (7 * x) + (25 * y) + 700
## [1] 2836
x <- 90
y <- 96 - x

(x^2 / 6) + (y^2 / 6) + (7 * x) + (25 * y) + 700
## [1] 2836
  1. Determine the results.

Answer: 75 units from Los Angeles, 21 units from Denver

Question 5:

Evaluate the double integral on the given region.

\(\int \int_{R} (e^{8x + 3y}) \ dA \ ; \ R: 2 \leq x \leq 4 \ and \ 2 \leq y \leq 4\)

Write your answer in exact form without decimals.

\(\int_2^4 \int_2^4 (e^{8x+3y}) \ dx \ dy\)

\(\int_2^4 \left[ \int_2^4 (e^{8x+3y}) \ dx \right] \ dy\)

\(\int_2^4 \left[ (e^{8x+3y}) \middle| _2^4 \ \right] \ dy\)

\(\int_2^4 \left[ (e^{8(4)+3y}) - (e^{8(2) + 3y}) \ \right] \ dy\)

\(\int_2^4 \left[ (e^{32+3y}) - (e^{16 + 3y}) \ \right] \ dy\)

\(\left[ \ (e^{32+3y}) - (e^{16 + 3y}) \ \middle|_2^4 \ \right] \ dy\)

\(e^{32+12} - e^{16 + 12} - e^{32 + 6} + e^{16 + 6}\)

\(e^{44} - e^{28} - e^{38} + e^{22}\)

Answer: (exact form)

\(e^{44} - e^{28} - e^{38} + e^{22}\)

exp(44) - exp(28) - exp(38) + exp(22)
## [1] 1.281974e+19