library(ggplot2)
Warning: package 'ggplot2' was built under R version 3.3.2

Homework 15

Week15 Problem Set -1
Solution
data1_df <- data.frame(xvalues=c(5.6, 6.3, 7, 7.7, 8.4), yvalues=c(8.8, 12.4, 14.8, 18.2, 20.8))
print (data1_df)
  xvalues yvalues
1     5.6     8.8
2     6.3    12.4
3     7.0    14.8
4     7.7    18.2
5     8.4    20.8
ggplot(data=data1_df, aes(x=xvalues, y=yvalues)) + geom_point()

m1 = lm(yvalues ~ xvalues, data=data1_df)
summary(m1)

Call:
lm(formula = yvalues ~ xvalues, data = data1_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 ***
xvalues       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
ggplot(data1_df, aes(xvalues, yvalues)) + geom_point(colour="blue", size=2) + 
    geom_abline(aes(slope=round(m1$coefficients[2], 2), intercept=round(m1$coefficients[1], 2))) +
    xlab("xvalues") + ylab("yvalues") + labs(title = "xvalues vs. yvalues")

\[ yvalues = -14.8 + (4.26 * xvalues) \]

Separator - 01
Week15 Problem Set -2
Solution

\(f(x,y) = 24x - 6xy^2 -8y^3\)
\(f_x(x, y) = \frac{\partial}{\partial x}(24x - 6xy^2 -8y^3) = 24-6y^2\)
\(f_y(x, y) = \frac{\partial}{\partial y}(24x - 6xy^2 -8y^3) = -12xy-24y^2\)

Setting \(f_x(x,y) = 0\), we can get the value of \(y\)
\(24-6y^2 = 0\)
\(6y^2 = 24\)
\(y^2 = 4\)
\(y = \pm 2\)

Setting \(f_y(x,y) = 0\) and by substituting value of \(y\), we can get \(x\)
\(-12xy-24y^2 = 0\)
\(-12xy = 24y^2\)
\(x = -2y\)

For \(y = 2\), \(x =-4\)
For \(y =-2\), \(x = 4\)

When we substitute these values back in the function:
\(f(x, y) = f(-4, 2) = (24x - 6xy^2 -8y^3) = [24(-4) - 6(-4)(2^2) -8(2)^3] = -64\)
\(f(x, y) = f(4, -2) = (24x - 6xy^2 -8y^3) = [24(4) - 6(4)(-2^2) -8(-2)^3] = 64\)

The critical points are \((-4, 2)\) and \((4, -2)\)
\((x, y, z) = (4, -2, 64)\) and \((-4, 2, -64)\)

We can do the Second Derivative test:
Let \(D = f_{xx}(x_0, y_0).f_{yy}(x_0, y_0) - f_{xy}^2(x_0, y_0)\) for a \(P\) if \(D<0\), then \(P\) is a saddle point of \(f\).

\(f_{xx}(x, y) = \frac{\partial}{\partial x}(f_{x}) = \frac{\partial}{\partial x}(24-6y^2) = 0\)
\(f_{yy}(x, y) = \frac{\partial}{\partial y}(f_{y}) = \frac{\partial}{\partial x}(-12xy-24y^2) = (-12x-48y)\)
\(f_{xy}(x, y) = \frac{\partial}{\partial y}(f_{x}) = \frac{\partial}{\partial y} (24-6y^2) = -12y\)

\(D(x_0, y_0) = f_{xx}(x_0, y_0).f_{yy}(x_0, y_0) - f_{xy}^2(x_0, y_0)\)
\(D(-4, 2) = (0)((-12*-4)-(48*2)) - (-12*2)^2 = -576\)
\(D(4, -2) = (0)((-12*4)-(48*(-2))) - (-12*(-2))^2 = -576\)

Since \(D(-4, 2)\) and \(D(4, -2)\) are both negative, we can say \((-4, 2)\) and \((4, -2)\) are the saddle points.

Separator - 02
Week15 Problem Set -3
Solution

If the manager sells the “house” brand for \(x\) dollars, she is able to sell \(81-21x+17y\).
If the manager sells the “name” brand for \(y\) dollars, she is able to sell \(40+11x-23y\)

\(Revenue\) = \(price\) X # \(of\) \(units\)
Therefore we can write the following:
\(R_1(x) = x*(81-21x+17y) = (81x-21x^2+17xy)\)
\(R_2(y) = y*(40+11x-23y) = (40y+11xy-23y^2)\)

(Step 1):
Now the total Revenue function \(R(x, y)\) would be:
\(R(x, y) = 81x-21x^2+17xy+40y+11xy-23y^2\)
\(R(x, y) = -21x^2+28xy-23y^2+81x+40y\)

(Step 2):
\(x = \$2.30\)
\(y = \$4.10\)
\(R(2.30, 4.10) = -21(2.30)^2+28(2.30*4.10)-23(4.10)^2+81(2.30)+40(4.10)\)
\(R(2.30, 4.10) = \$116.62\)

The total revenue if the manager sells the “house” brand for \(\$2.30\) and “name” brand for \(\$4.10\) is \(\$116.62.\)
Separator - 03
Week15 Problem Set -4
Solution

The total weekly cost is given by the following function:
\(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.
Since the company is committed to produce a total of \(96\) units of a product each week, \(x + y = 96\)
\(x = 96 - y\)
\(C(96-y, y) = \frac{1}{6}(96-y)^2 + \frac{1}{6}y^2 + 7(96-y) + 25y +700\)
\(C(96-y, y) = \frac{1}{6}(y^2-192y+9216)+\frac{1}{6}y^2 + 18y+1372\)
\(C(96-y, y) = \frac{1}{3}y^2-14y+2908\)

To find the minimum value, we need to differentiate the function \(C(x, y)\) and equate it to \(0\).
\(C^{'}(96-y, y) = \frac{d}{dy}(\frac{1}{3}y^2-14y+2908) = \frac{2}{3}y-14\)
\(\frac{2}{3}y-14 = 0\)
\(y = 21\)

Substituting the value of \(y\) in the equation, we get \(x = 96 - y\)
\(x = 96-21\)
\(x = 75\)

Therefore, the company needs to product \(75\) units in Los Angeles plant and \(21\) units in Denver plant to minimize the total weekly cost.

Separator - 04
Week15 Problem Set -5
Solution

\(\int\int_R e^{(8x+3y)}dA = \int_2^4\int_2^4 e^{(8x+3y)}dy dx\)
Let’s integrate the interal part first: \(\int_2^4e^{(8x+3y)}dy\)
Let \(u = (8x+3y)\)
\(\frac{du}{dy} = 3 \Rightarrow dy = \frac{1}{3} du\)
Therefore \(\int_2^4e^{(8x+3y)}dy = \frac{1}{3}\int_2^4 e^u du = \frac{1}{3}(e^{u}\vert_2^4)\)
Substituting \((8x+3y)\) for \(u\), we get \(\int_2^4e^{(8x+3y)}dy = \frac{1}{3} [e^{(8x+12)} - e^{(8x+6)}]\)
Substituting the interal part we get:

\(\int_2^4\int_2^4 e^{(8x+3y)}dy dx = \int_2^4(\frac{1}{3} [e^{(8x+12)} - e^{(8x+6)}])dx\)
\(\int_2^4[\frac{1}{3} e^{(8x+12)}]dx - \int_2^4[\frac{1}{3} e^{(8x+6)}]dx\)
\(\frac{1}{3}.\frac{1}{8}.e^{(8x+12)}\vert_2^4 - \frac{1}{3}.\frac{1}{8}.e^{(8x+6)}\vert_2^4\)
\(\frac{1}{24}[e^{(32+12)} - e^{(16+12)}] - \frac{1}{24}[e^{(32+6)} - e^{(16+6)}]\)

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