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)

library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr     1.1.4     ✔ readr     2.1.5
## ✔ forcats   1.0.0     ✔ stringr   1.5.1
## ✔ ggplot2   3.4.4     ✔ tibble    3.2.1
## ✔ lubridate 1.9.3     ✔ tidyr     1.3.1
## ✔ purrr     1.0.2     
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
x <- c(5.6, 6.3, 7, 7.7, 8.4)
y <- c(8.8, 12.4, 14.8, 18.2, 20.8)

# find the mean of each variable
x_bar <- mean(x)
y_bar <- mean(y)

# find standard deviation of x and y 
std_x <- sd(x)
std_y <- sd(y)

# find the correlation
r <- cor(x, y)

slope <- (std_y/std_x) * r

Using the mean of x, the mean of y, the slope, and the point slope form we can find the equation of the line.

\(y - \overline{y} = b_1(x - \overline{x})\)

\(y - 15 = 4.26(x - 7)\)

\(y - 15 = 4.26x - 29.82\)

\(y = 4.26x - 14.82\)

# Create a linear regression model to find the coefficients 
m_df <- as_tibble(cbind(x,y))

m_lm <- lm(y~x, data = m_df)

plot(m_df$x, m_df$y, xlab = "x", ylab = "y")
abline(m_lm)

summary(m_lm)
## 
## Call:
## lm(formula = y ~ x, data = m_df)
## 
## Residuals:
##     1     2     3     4     5 
## -0.24  0.38 -0.20  0.22 -0.16 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept) -14.8000     1.0365  -14.28 0.000744 ***
## x             4.2571     0.1466   29.04 8.97e-05 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.3246 on 3 degrees of freedom
## Multiple R-squared:  0.9965, Adjusted R-squared:  0.9953 
## F-statistic: 843.1 on 1 and 3 DF,  p-value: 8.971e-05

Using this method we get \(y = 4.26x - 14.8)\), which is roughly the same as manually calculating it.

Question 2:

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 - 6xy2 - 8y3\)

  1. To start we will find the partial derivatives with respect to x and with respect to y

The partial derivative with respect to x:

\(f_x(x,y) = 24 - 6y^2\)

The partial derivative with respect to y:

\(f_y(x,y) = -12xy - 24y^2\)

  1. We will set each partial derivative to 0 and solve for the respective variable

\(f_x(x,y) = 24 - 6y^2\)

\(f_x(x,y) = 24 - 6y^2 = 0\)

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

\(y^2 = \frac{-24}{-6}\)

\(y = \sqrt{4}\)

\(y = pm 2\)

\(fy(x,y) = -12xy - 24y^2\)

\(fy(x,y) = -12xy - 24y^2 = 0\)

\(-12xy = 24y^2\)

\(x = \frac{24y^2}{-12y}\)

\(x = -2y\)

Substitute \(y = \pm 2\) into the equation

\(x = -2 (\pm 2)\)

\(x = \pm 4\)

With the following points for (x, y) we need to compute \(z = f(x,y)= 24x - 6xy2 - 8y3\) for each instance (4, -2) and (-4, 2).

find_z <- function(x,y){
  z <- (24 * x) - (6 * x * (y**2)) - (8 * y**3)
  return(z)
}

When x = 4 and y = -2; z = 64

When x = -4 and y = 2; z = -64

With the following critical points we can determine if they are minima, maxima or saddle points and to do so we need to use the second derivative test. \[ (4, -2, 64)\\ (-4, 2, -64) \]

D is defined as \(D(x,y)=D=f_{xx}(x,y)f_{yy}(x,y)-[f_{xy}(x, y)]^{2}\)

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

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

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

Find minima, maxima and saddle points using the following criteria. If D > 0 and fxx > 0, then local min if D > 0 and fxx < 0 then local max If D < 0 then saddle point

\(D(x,y)=D=f_{xx}(x,y)f_{yy}(x,y)-[f_{xy}(x, y)]^{2}\) \(D = (0)*(-12x - 48y)-(12y)^2\) \(D = 0- 144y^2\)

D < 0 for any point so we can conclude that the two points \((4, -2, 64)\) and \((-4, 2, -64)\) are saddle points.

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

House brand revenue at x dollars/unit \(x * (81 - 21x + 17y) = 81x-21x^2 +17xy\)

Name brand revenue at y dollars/unit

\(y * (40 + 11x - 23y) = 40y + 11xy -23y^2\)

Revenue function:

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

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

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

revenue <- function(x,y){
  r <- (81 * x) - (21 * (x**2)) + (28 * x * y) + (40 * y) - (23 * (y**2))
  return(r)
}

The revenue this manager can expect is 116.62 dollars.

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?

We can find the minimum cost by calculating the critical points of C(x,y) and where the partial derivatives with respect to each variable x and y are both 0.

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

The partial derivative with respect to x

\(\frac{\partial C}{\partial x} = \frac{1}{6}x^2 + 7x\)

\(\frac{\partial C}{\partial x} = \frac{1}{3}x + 7\)

The partial derivative with respect to y

\(\frac{\partial C}{\partial y} = \frac{1}{6}y^2 + 25y\)

\(\frac{\partial C}{\partial y} = \frac{1}{3}y + 25\)

Since we want to minimize the partial derivatives we want to set them both = to 0 and solve for x and y respectively.

Solve for x:

\(\frac{1}{3}x + 7 = 0\) \(\frac{x}{3} = -7\) \(\frac{3}{1} * \frac{x}{3} = -7 * \frac{3}{1}\) \(x = -21\)

Solve for y:

\(\frac{1}{3}y + 25 = 0\) \(\frac{y}{3} = -25\) \(\frac{3}{1} * \frac{y}{3} = -25 * \frac{3}{1}\) \(x = -75\)

We verify that this point is indeed a minimum by evaluating whether or not the second order derivatives are both positive constants and as shown below, they are.

\(\frac{\partial C}{\partial x} = \frac{1}{3}x + 7\)

\(C_{xx} = \frac{1}{3}x + 7\)

\(\frac{\partial C}{\partial y} = \frac{1}{3}y + 25\)

\(C_{yy} = \frac{1}{3}\)

To minimize the total weekly cost the company in LA should produce 21 units and the company in Denver should produce 75 units.

Question 5:

Evaluate the double integral on the given region.

$(e^{8x+3y})dA; R: 2 x and 2 y $

\[\iint(e^{8x+3y})dA = \\ \int^4_2\int^4_2e^{8x + 3y}dy~dx \]

Integrate with respect to y then with respect to x

\[\int^4_2\int^4_2e^{8x + 3y}dy~dx = \\ \int_2^4 [\frac{1}{3}e^{8x + 3y}]_{y=2}^{y=4} \\ \int_2^4 (\frac{1}{3}e^{8x + 12} - \frac{1}{3}e^{8x+6})dx \\ \frac{1}{3}\int_2^4e^{8x+12}dx - \frac{1}{3}\int_2^4e^{8x+6}dx \] Integrate each term separately

\[ \frac{1}{3}[\frac{1}{8}e^{8x+12}]_{x=2}^{x=4} - \frac{1}{3}[\frac{1}{8}e^{8x+6}]_{x=2}^{x=4} \\ \frac{1}{24}(e^{44} - e^{28}) - \frac{1}{24}(e^{38} - e^{22}) \\ \frac{1}{24}(e^{22} - e^{28} - e^{38} + e^{44}) \]

(exp(1)**22) - (exp(1)**28) - (exp(1)**38) + (exp(1)**44) * (1/24)
## [1] 5.03626e+17

5.03626e+17 = 503,626,000,000,000,000