Você está na página 1de 18

Final

PREDICT_400DL_SEC59
Moin Uddin Siddique

1. A local copy center needs to buy white paper and yellow paper. They can buy from
three suppliers. Supplier 1 sells a package of 20 reams of white and 10 reams of yellow
for $60. Supplier 2 sells a package of 10 reams of white and 10 reams of yellow for $40.
Supplier 3 sells a package of 10 reams of white and 20 reams of yellow for $50. The
copy center needs 350 reams of white and 400 reams of yellow. Using Python,
determine (1) how many packages they should buy from each supplier in order to
minimize cost and (2) the minimum cost.

Ans: Assuming x1, x2, and x3 as the number of packages the local copy center should buy
from supplier 1, 2, and 3 respectively in this problem, we have to minimize,

z = 60x1 + 40x2 + 50x3.

Let’s use python to solve the problem.

from scipy.optimize import linprog

z = [60, 40, 50]


lhs = [[-20,-10, -10], [-10, -10, -20]]
rhs = [-350, -400]
x1_bounds = (0, None)
x2_bounds = (0, None)
x3_bounds = (0, None)
method='simplex'

res = linprog(c=z, A_ub=lhs, b_ub=rhs,


bounds=(x1_bounds,x2_bounds, x3_bounds))

print('Minimized cost:', res.fun, '\n x1, x2, x3 :', res.x)


print('\n')

Result:
Minimized cost: 1350.0
x1, x2, x3 : [ 10. 0. 15.]

They should buy 10 packages from supplier 1 and 15 packages from supplier 2 for the minimum
cost of $1350.
2. A new test has been developed to detect a particular type of cancer. A medical
researcher selects a random sample of 1,000 adults and finds (by other means) that 4%
have this type of cancer. Each of the 1,000 adults is given the new test and it is found
that the test indicates cancer in 99% of those who have it and in 1% of those who do
not. Based on these results, what is the probability of a randomly chosen person having
cancer given that the test indicates cancer? What is the probability of a person having
cancer given that the test does not indicate cancer? Round the probabilities to four
decimal places.

Ans: Let, C indicating people having actual cancer and T indicating Test positive for cancer.

For convenience, I’m uploading a hand written note below –


So, the probability of a randomly chosen person having cancer given that the test indicates
cancer is 0.8049 (Rounded to four DP)
and
the probability of a person having cancer given that the test does not indicate cancer is .0004
(Rounded to four DP).

3. If a tank holds 5000 gallons of water, which drains from the bottom of the tank in 40
minutes, then the volume of the water remaining in the tank after 𝑡 minutes is given by
𝑡 2
𝑉(𝑡) = 5000 (1 − 40) , 0 ≤ 𝑡 ≤ 40. Using Python, determine the rate at which water
is draining from the tank. When will it be draining the fastest?

Ans: The rate of change of a function can be derived by finding the derivative of that
function. Let’s find that using python.

from __future__ import division


from sympy import *
x, y, z, t = symbols('x y z t')
diff(5000*((1-(t/40))**2), t)

Out[1]: 25*t/4 – 250

So, the rate is V’(t) = 25*x/4 – 250.


Let’s check the fastest draining time.

if __name__=="__main__":
deriv = [-(25*t/4 - 250) for t in range(0,41)] # minus in the begining is for making this function
concave
time_index = 0
val_index = 0
maximum = -999
for ind,val in enumerate(deriv):
print("Draining rate at time {} is {}".format(ind,val))
if(val>=maximum):
maximum = val
time_index = ind
print("\nThe Fastest Draining was in time {}, and the rate was
{}".format(time_index,maximum))
Results:
Draining rate at time 0 is 250.0
Draining rate at time 1 is 243.75
Draining rate at time 2 is 237.5
Draining rate at time 3 is 231.25
Draining rate at time 4 is 225.0
Draining rate at time 5 is 218.75
Draining rate at time 6 is 212.5
Draining rate at time 7 is 206.25
Draining rate at time 8 is 200.0
Draining rate at time 9 is 193.75
Draining rate at time 10 is 187.5
Draining rate at time 11 is 181.25
Draining rate at time 12 is 175.0
Draining rate at time 13 is 168.75
Draining rate at time 14 is 162.5
Draining rate at time 15 is 156.25
Draining rate at time 16 is 150.0
Draining rate at time 17 is 143.75
Draining rate at time 18 is 137.5
Draining rate at time 19 is 131.25
Draining rate at time 20 is 125.0
Draining rate at time 21 is 118.75
Draining rate at time 22 is 112.5
Draining rate at time 23 is 106.25
Draining rate at time 24 is 100.0
Draining rate at time 25 is 93.75
Draining rate at time 26 is 87.5
Draining rate at time 27 is 81.25
Draining rate at time 28 is 75.0
Draining rate at time 29 is 68.75
Draining rate at time 30 is 62.5
Draining rate at time 31 is 56.25
Draining rate at time 32 is 50.0
Draining rate at time 33 is 43.75
Draining rate at time 34 is 37.5
Draining rate at time 35 is 31.25
Draining rate at time 36 is 25.0
Draining rate at time 37 is 18.75
Draining rate at time 38 is 12.5
Draining rate at time 39 is 6.25
Draining rate at time 40 is -0.0

The Fastest Draining was in time 0, and the rate was 250.0
4. A rectangular container with a volume of 475 ft3 is to be constructed with a square base
and top. The cost per square foot for the bottom is $0.20, for the top is $0.10, and for
the sides is $0.015. Find the dimensions of the container that minimize the cost. Round
to two decimal places.

Ans:
A rectangular container is like a rectangular prism. Volume of a rectangular prism is, V =
Length (l) * Width (w) * Height (h).
The container has a square base and top. That means its length & width is same.
So, in our case, V = l*l*h = l^2 * h

Given, Volume = 475


Or, l^2*h = 475
Or, h = 475/l^2

The surface area of the top and bottom is l^2. The surface area of the lateral sides is 4lh.

Cost, C = Cost of bottom + Cost of top + Cost of sides


= (0.20)l^2 + (0.10)l^2 + (0.015)(4lh)
Substituting h=475/l^2,
C = (0.3)l^2 + (0.015)(4*l*475/l^2)
= (0.3)l^2 + (28.5)/l

To find the minimum cost, we should take the first derivative of Cost with respect to l, set it to
zero, and solve for l.

dC/dl = (0.6)l – 28.5/l^2


(0.6)l – 28.5/l^2 = 0
Or, (0.6)l^3 – 28.6 = 0
Or, l^3 = 28.6/0.6
Or, l = 47.67^(1/3)
Or, l ≅ 3.63

h = 475/3.63^2 ≅ 36.05

So, the dimension is, (3.63 X 36.05).


5. Assume the total revenue from the sale of 𝑥 items is given by 𝑅(𝑥) = 27 ln(6𝑥 + 1)
while the total cost to produce 𝑥 items is 𝐶(𝑥) = 𝑥⁄7. Find the approximate number of
items that should be manufactured so that profit is maximized. Justify that the number
of items you found gives you the maximum and state what the maximum profit is.

Ans: Profit = Revenue – Cost


So, P(x) = R(x) – C(x)
Or, P(x) = 27ln(6x + 1) – x/7
We need to find dP(x)/dx.
dP(x)/dx = 27 (6/6x +1) – 1/7
= 162/(6x+1) – 1/7
Let’s set it equal to 0.
162/(6x+1) – 1/7 = 0
Or, 162/(6x+1) = 1/7
Or, 1134 = 6x +1
Or, x = 1133/6 = 188.83333333333334
So, x ≅ 189

189 items should be manufactured in order to maximize the profit.


The profit will be P(189) = 27ln(6(189) + 1) - 189/7
= 27ln(1135) – 189/7
= 162.928474108 ≅ 162.93

Justification: We first took the derivative of the profit function with respect to x and set the
equation equal to 0 in order to find the critical point and hence the point where profit is
maximum. Let’s try to put some other value to check whether my claim is true or not. Let’s
check for 188, 190 item and their profit accordingly.

P(188) = 27ln(6(188) + 1) - 188/7 = 162.928221375 which is < 162.928474108

P(190) = 27ln(6(190) + 1) - 190/7 = 162.927972303 which is < 162.928474108

So, as we can see the profit increases till 189 item and starts decreasing after that.
6. For the following function, determine the domain, critical points, intervals where the
function is increasing or decreasing, inflection points, intervals of concavity, intercepts,
and asymptotes where applicable. Use this information and Python to graph the
function.

1
𝑓(𝑥) = − +4
(𝑥 + 2)2
Ans:
Let’s graph the function with these information in python:
def graph(formula, x_range):
x = np.array(x_range)
y = eval(formula)
plt.plot(x, y)
plt.show()

graph('-1/(x+2)**2 +4', x_range = np.arange(-20.0, 20.0, 0.1))

plt.plot(-3/2,0,'ro', color = 'k')


plt.plot(-5/2,0,'ro', color = 'k')
plt.plot(0, 15/4,'ro', color = 'k')
plt.axvline(x=-2, linewidth=2, color='b')
plt.axvline(x=0, linewidth=2, color='k')
plt.axhline(y=0, linewidth=2, color='k')
plt.axhline(y=4, linewidth=2, color='b')
plt.ylim([-10, 10])
plt.grid(True)
plt.legend(['y = -1/(x+2)**2 +4'], loc='upper left')

Result:
7. The rate of growth of the profit (in millions) from an invention is approximated by the
2
function 𝑃′ (𝑥) = 𝑥𝑒 −𝑥 where 𝑥 represents time measured in years. The total profit in
year two that the invention is in operation is $25,000. Find the total profit function.
Round to three decimals.

Ans:

P'(x) = xe^-x^2

Or, P(x) = integral (xe-x^2) dx

let -x^2 = u

so, du = -2x dx

Then, integral (xe^-x^2) dx = integral -½ e^u du = -½ e^u + c

Therefore, p(x) = -½ e^-x^2 + c

P(2) = -½ e^-2^2 + c =25000


Or, c = 25,000 + 1/2e^4 or 25000.009 (rounded to three decimal)

Therefore, p(x) = - ½ e^-x^2 + (25000 + 1/2e^4) or - ½ e^-x^2 + 25000.009


8. For a certain drug, the rate of reaction in appropriate units is given by

6 1
𝑅 ′ (𝑡) = +
𝑡 + 1 √𝑡 + 1

where 𝑡 is time (in hours) after the drug is administered. Find the total reaction to the
drug from 1 to 8 hours after it is administered. Round to two decimal places.

Ans:
9. Determine if the following function is a probability density function on[0, ∞).

𝑥 3⁄ , 𝑖𝑓 0 ≤ 𝑥 ≤ 2
𝑓(𝑥) = { 8
4⁄ , 𝑖𝑓 𝑥 > 2
𝑥3

If it is a probability density function, then calculate 𝑃(1 ≤ 𝑥 ≤ 5) and round to four


decimal places. If it is not, explain why.

Ans:
The function needs to meet two conditions to be a pdf.
1. F(x) cannot be negative.
2. Total probability should equal to 1.
The first condition holds. The probability will never be negative on the given intervals.

The main interval has been separated and made into two intervals. So, we’ll check both parts of
the function and add the results to see whether f(x) is a pdf.

On [0,2], f(x) = x^3/8


2 2
∫0 𝑥 3 /8 = 1/8 ∫0 𝑥 3 = 1/8 2^4/4 – 0 = 16/32 = ½

On (2, ∞), f(x) = 4/x^3


∞ ∞
∫2 4/𝑥 3 = 4 ∫2 𝑥 −3 = 0 – (4 * 1/2*2^2 = ½

Total Probability = ½ + ½ = 1. [Condition 2 holds]



∫ 𝑓(𝑥) 𝑑𝑥 = 1
0

So we can call f(x) a probability density function.

Let’s calculate 𝑃(1 ≤ 𝑥 ≤ 5).

5
P(1≤x≤5) = ∫1 𝑓(𝑥) 𝑑𝑥

2 5
= ∫1 𝑓(𝑥) 𝑑𝑥 + ∫2 𝑓(𝑥) 𝑑𝑥
=1/8 (2^4/4 – 1^4/4) + 4(-1/2*5^2 + 1/2*2^2)
= 31/32 – 2/25 = 0.8888 (rounded to four decimal places)
10. Researchers have shown that the number of successive dry days that occur after a
rainstorm for a particular region is a random variable that is distributed exponentially
with a mean of 9 days. Using Python, determine the (separate) probabilities that 13 or
more successive dry days occur after a rainstorm, and fewer than 2 dry days occur after
a rainstorm. Round the probabilities to four decimal places.
Let’s get this last problem done with python.

from __future__ import division


from sympy import *
x, y, z, t = symbols('x y z t')
integrate(1/9*exp(-x/9), (x, 13, oo)) # probabilities that 13 or more successive dry days
Out[7]: 1.0*exp(-13/9)

= 0.2359 (rounded to four decimal point)

For probability of fewer than 2 dry days occur after a rainstorm:

integrate(1/9*exp(-x/9), (x, 0, 2))

Out[8]: -1.0*exp(-2/9) + 1.0

= 0.1993 (rounded to four decimal point)

So probability of 13 or more successive dry days is 0.2359

Probability of fewer than 2 dry days is 0.1993.

*Excuse me for bad hand writing

Você também pode gostar