Answers to Ma 162 Spring 2005 final

>    with(linalg):

Q.1.

>    eq1:=x+y+z=100000; ## Total Investment

>   

eq1 := x+y+z = 100000

>    eq2:=(10*x+6*y+2*z)/100=8000; ##Income

eq2 := 1/10*x+3/50*y+1/50*z = 8000

>    eq3:=z=20*x/100+10*y/100; ##Extra condition

eq3 := z = 1/5*x+1/10*y

>    M:=matrix(3,4,[1,1,1,100000,1/10,3/50,1/50,8000,1/5,1/10,-1,0]);##Augmented matrix

M := matrix([[1, 1, 1, 100000], [1/10, 3/50, 1/50, 8000], [1/5, 1/10, -1, 0]])

>    A:=matrix(3,4,[1,1,1,100,5,3,1,400,2,1,-10,0]);
##This is same as above, except the variables are scaled to 1000's of dollars and equations simplified.

A := matrix([[1, 1, 1, 100], [5, 3, 1, 400], [2, 1, -10, 0]])

>    A1:=addrow(A,1,2,-5);

A1 := matrix([[1, 1, 1, 100], [0, -2, -4, -100], [2, 1, -10, 0]])

>    A2:=addrow(A1,1,3,-2);

A2 := matrix([[1, 1, 1, 100], [0, -2, -4, -100], [0, -1, -12, -200]])

>    A3:=addrow(A2,2,3,-1/2);

A3 := matrix([[1, 1, 1, 100], [0, -2, -4, -100], [0, 0, -10, -150]])

Now solve by backsub. if we let maple to the work, then:

>    gaussjord(A);

matrix([[1, 0, 0, 65], [0, 1, 0, 20], [0, 0, 1, 15]])

>    x=65,y=20,z=15; ##Final answer read off.

>   

x = 65, y = 20, z = 15

Q.2

Let x,y be resp. the number of days of operation of the two mines saddle and Horseshoe.

>    ## Cost calculations
C:=14*x+16*y ;## Cost in thousand dollars!

C := 14*x+16*y

>    ## Gold target
ineq1:=50*x+75*y>=650;

ineq1 := 650 <= 50*x+75*y

>    ##Silver target
ineq2:=3*x+y>=18; ##Target in 1000 ounces

ineq2 := 18 <= 3*x+y

>    ##Natural constraints
x>=0,y>=0;

0 <= x, 0 <= y

The set up is to minimize C as above subject to the listed inequalities.

Q.3.

>    ## The region has four corners P,Q,R,S where
P:=[0,0];Q:=[4,0];S:=[0,6];

P := [0, 0]

Q := [4, 0]

S := [0, 6]

>    sol:=solve({x+y=6,2*x+y=8},{x,y});

sol := {y = 4, x = 2}

>    R:=subs(sol,[x,y]);

R := [2, 4]

>    chval:=(p,f)->subs([x=p[1],y=p[2]],f);

chval := (p, f) -> subs([x = p[1], y = p[2]],f)

>    ["P"=P,chval(P,2*x+6*y)];["Q"=Q,chval(Q,2*x+6*y)];["R"=R,chval(R,2*x+6*y)];["S"=S,chval(S,2*x+6*y)];

[

[

[

[

So the max. is at S =[0,6]

Q.4.

>    ans[a]:=(110-39)/110;
## remove non drinkers, you have the union of the coffee and tea drinker sets.

ans[a] := 71/110

>    ans[b]:=(52+41-71)/110;
## find intersection by usual formula. The numerator is 22

ans[b] := 1/5

>    ans[c]:=(52-22)/110;
## coffee drinkers minus both coffee and tea drinkers.

ans[c] := 3/11

>    ans[d]:=[52/110*41/110,22/110];

ans[d] := [533/3025, 1/5]

>    evalf(%);

[.1761983471, .2000000000]

The probabilty of the intersection and the product of two probabilities are within 0.5 so in a crude sense they are independent. If the required agreement is stricter, then they are not!

Q.5.

>    with(combinat):

>    ans[a]:=numbcomb(120,7);## Sample space size. Choices of 7 tapes from 120 form the sample space.

ans[a] := 59487568920

>    ans[b]:=numbcomb(15,2)*numbcomb(105,5)/numbcomb(120,7);evalf(%);

ans[b] := 509747/2990828

.1704367486

>    ## First find the prob. of no defective tapes and subtract from 1.
goodtapes:=numbcomb(105,7)/numbcomb(120,7);
ans[c]:=evalf(1-goodtapes);

goodtapes := 572165/1495414

ans[c] := .6173868909

>    ans[d]:=evalf(goodtapes);

ans[d] := .3826131091

Q.6. Sample space is the set of 400 seniors.

>    maleprob:=evalf(150/400);femaleprob:=evalf(250/400);

maleprob := .3750000000

femaleprob := .6250000000

>    ## Path: female and with D.L.
ans[a]:=femaleprob*0.70;

ans[a] := .4375000000

>    ## Path male and with D.L.
ans[b]:=maleprob*0.50;

ans[b] := .1875000000

>    ## Paths ending with D.L. -> the above two paths added.
ans[c]:=ans[a]+ans[b];

ans[c] := .6250000000

>    ## The population with no D.L. has two paths:
femaleprob*0.30+maleprob*0.5;

.3750000000

>    ## out of these, one path has all the females.
femaleprob*0.30;

.1875000000

>    ## So the  probability is:
ans[d]:=(maleprob*0.50)/(femaleprob*0.30+maleprob*0.5);

ans[d] := .5000000000

>   

>   

>