#1

Question:

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 )

Work and Answer:

x1=c(5.6,6.3,7,7.7,8.4)
y1=c(8.8,12.4,14.8,18.2,20.8)

model1=lm(y1 ~ x1)

slope1=round(coef(model1)[2],2)
intercept1=round(coef(model1)[1],2)

cat("The equation for the regression line is: \n", "y=",slope1,"x+",intercept1, "\n")
## The equation for the regression line is: 
##  y= 4.26 x+ -14.8

#2

Question:

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

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

Work and answer:

library(pracma)
## Warning: package 'pracma' was built under R version 4.3.2
f2 = function(x, y) {
  24*x - 6*x*y^2 - 8*y^3
}
f2_xx = function(x, y) {
  0
}
f2_yy = function(x, y) {
  -12*x
}
f2_xy = function(x, y) {
  -12*y
}

#critical points
critical_points = matrix(c(2, 2, -2, -2), ncol = 2, byrow = TRUE)

# Evaluate function at critical points
f2_values = apply(critical_points, 1, function(point) f2(point[1], point[2]))

# Classify each critical point
for (i in 1:nrow(critical_points)) {
  x = critical_points[i, 1]
  y = critical_points[i, 2]
  D = f2_xx(x, y) * f2_yy(x, y) - f2_xy(x, y)^2
  
  if (D > 0) {
    if (f_xx(x, y) > 0) {
      point_type = "local minimum"
    } else {
      point_type = "local maximum"
    }
  } else if (D < 0) {
    point_type = "saddle point"
  } else {
    point_type = "inconclusive"
  }
  
  cat(sprintf("The critical point (%.2f, %.2f, %.2f) is a %s.\n", x, y, f2_values[i], point_type))
}
## The critical point (2.00, 2.00, -64.00) is a saddle point.
## The critical point (-2.00, -2.00, 64.00) is a saddle point.

#3

Question:

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

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

Work and Answer:

#revenue function

rf = function(x, y) {
  x * (81 - 21*x + 17*y) + y * (40 + 11*x - 23*y)
}


revenue = rf(2.30, 4.10)


cat("If she sells the 'house' brand for $2.30 and the 'name' brand for $4.10, \n she will make $",revenue," as her revenue. \n")
## If she sells the 'house' brand for $2.30 and the 'name' brand for $4.10, 
##  she will make $ 116.62  as her revenue.

#4

Question:

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?

Work and Answer:

cost_f = function(x, y) {
  (1/6) * x^2 + (1/6) * y^2 + 7 * x + 25 * y + 700
}

#partial derrivatives 

p_x = function(x, y) {
  (1/3) * x + 7
}
p_y = function(x, y) {
  (1/3) * y + 25
}

# y in terms of x
y_of_x = function(x) {
  96 - x
}


optimize(function(x) cost_f(x, y_of_x(x)), lower = 0, upper = 96)$minimum
## [1] 75
op_x = optimize(function(x) cost_f(x, y_of_x(x)), lower = 0, upper = 96)$minimum
op_y = y_of_x(op_x)


cat("To minimize the total weekly cost, \n the Los Angeles plant must produce",op_x,"\n the Denver plant must produce",op_y)
## To minimize the total weekly cost, 
##  the Los Angeles plant must produce 75 
##  the Denver plant must produce 21

#5

Question

Evaluate the double integral on the given region.

\[ \iint (e^{8x+3y})dA;\\ R: 2 \leq x \leq 4,\\ 2 \leq y \leq 4 \]

Write your answer in exact form without decimals.

Work and Answer

f5 = function(x, y) {
  exp(8*x + 3*y)
}


result5 = integral2(f5, 2, 4, 2, 4)


cat("The answer in exact form is",format(result5$Q, scientific=FALSE), "\n")
## The answer in exact form is 534155947871807104