FINITE CHAPTER 1 - Linear Functions
Section 1.3, page 38
Problem 10
We can use Maple's least squres function for this data as follows:
| > | with(stats): |
| > | year:=[88,89,90,91,92,93,94]; apps:=[27,27,29,33,37,43,45]; |
![]()
![]()
| > | line:=fit[leastsquare[[x,y]]]([year,apps]); |

| > | evalf(line); |
![]()
We'll plot the data and the line to see how good it is:
| > | with(plots,display): |
| > | A:=plot([zip((x,y)->[x,y],year,apps)],style=point,color=blue,thickness=2): |
| > | B:=plot(rhs(line),x=87..95,color=blue,thickness=2): |
| > | display({A,B}); |
![[Maple Plot]](images/m115-exf5.gif)
So the fit looks pretty good. We can get the correlation coefficient as follows:
| > | describe[linearcorrelation](year,apps); |

| > | evalf(%); |
![]()
This is a high correlation, which supports our use of the linear function. But the differences between the points and the line, while small, seem to have a pattern, which may indicate that a different function would be better.
FINITE CHAPTER 2 - Linear Equations and Matrices
Section 2.1, page 57
Problem 25
This is easy in Maple using solve:
| > | solve({x+3*y+4*z=14,2*x-3*y+2*z=10,3*x-y+z=9}); |
![]()
Problem 29
Since we want z to be the parameter in this one, we solve for x and y.
| > | solve({3*x+y-z=0,2*x-y+3*z=-7},{x,y}); |

Section 2.2, page 70
Problem 28
We could use Maple's solve, but we'll do this in matrix form anyway:
| > | with(linalg): |
Warning, the protected names norm and trace have been redefined and unprotected
| > | M:=matrix(3,4,[1,0,-1,-3,0,1,1,9,-1,0,1,3]); |
![M := matrix([[1, 0, -1, -3], [0, 1, 1, 9], [-1, 0, 1, 3]])](images/m115-exf10.gif)
| > | gaussjord(M); |
![matrix([[1, 0, -1, -3], [0, 1, 1, 9], [0, 0, 0, 0]])](images/m115-exf11.gif)
| > | backsub(gaussjord(M)); |
![]()
This shows that z is a free parameter, and y=9-z and x=z-3.
Problem 40
| > | M:=matrix(3,5,[4,-3,1,1,21,-2,-1,2,7,2,10,0,-5,-20,15]); |
![M := matrix([[4, -3, 1, 1, 21], [-2, -1, 2, 7, 2], [10, 0, -5, -20, 15]])](images/m115-exf13.gif)
| > | gaussjord(M); |
![matrix([[1, 0, -1/2, -2, 3/2], [0, 1, -1, -3, -5], [0, 0, 0, 0, 0]])](images/m115-exf14.gif)
| > | backsub(gaussjord(M)); |
![vector([3/2+1/2*_t[2]+2*_t[1], -5+_t[2]+3*_t[1], _t[2], _t[1]])](images/m115-exf15.gif)
This time, z and w are free parameters, x is 3/2+1/2 z +2w, and y is -5 + z + 3w.
Section 2.3, page 81
Problem 29
Maple can add matrices:
| > | matrix(2,2,[1,5,-3,7])-matrix(2,2,[6,3,2,4])+matrix(2,2,[8,10,-1,0]); |
![matrix([[1, 5], [-3, 7]])-matrix([[6, 3], [2, 4]])+matrix([[8, 10], [-1, 0]])](images/m115-exf16.gif)
| > | evalm(%); |
![matrix([[3, 12], [-6, 3]])](images/m115-exf17.gif)
Section 2.4, page 92
Problem 30
| > | matrix(2,2,[2,-2,1,-1])&*matrix(2,2,[4,3,1,2])+ matrix(2,2,[2,-2,1,-1])&*matrix(2,2,[7,0,-1,5]); |
![`&*`(matrix([[2, -2], [1, -1]]),matrix([[4, 3], [1, 2]]))+`&*`(matrix([[2, -2], [1, -1]]),matrix([[7, 0], [-1, 5]]))](images/m115-exf18.gif)
| > | evalm(%); |
![matrix([[22, -8], [11, -4]])](images/m115-exf19.gif)
Section 2.5, page 105
Problem 21
| > | inverse(matrix(3,3,[1,2,3,-3,-2,-1,-1,0,1])); |
Error, (in inverse) singular matrix
Let's verify that:
| > | det(matrix(3,3,[1,2,3,-3,-2,-1,-1,0,1])); |
![]()
Problem 23
| > | inverse(matrix(3,3,[2,4,6,-1,-4,-3,0,1,-1])); |
![matrix([[7/4, 5/2, 3], [-1/4, -1/2, 0], [-1/4, -1/2, -1]])](images/m115-exf21.gif)
Let's verify this, too:
| > | evalm(%&*matrix(3,3,[2,4,6,-1,-4,-3,0,1,-1])); |
![matrix([[1, 0, 0], [0, 1, 0], [0, 0, 1]])](images/m115-exf22.gif)
Section 2.6, page 113
Problem 17
With yams in the first row/column, and pigs in the second, the input-output matrix is
| > | A:=matrix(2,2,[1/4,1/6,1/2,0]); |
![A := matrix([[1/4, 1/6], [1/2, 0]])](images/m115-exf23.gif)
(we're not going to ask how they produce pigs from yams [and no other pigs]). Meanwhile, we'll need
| > | Id:=matrix(2,2,[1,0,0,1]); |
![Id := matrix([[1, 0], [0, 1]])](images/m115-exf24.gif)
(a) To produce 1 bushel of yams and 1 pig:
| > | evalm((Id-A)^(-1)&*matrix(2,1,[1,1])); |
![matrix([[7/4], [15/8]])](images/m115-exf25.gif)
So we need 7/4 bushels of yams and 2 pigs.
(b) For 100 bushels and 70 pigs:
| > | evalm((Id-A)^(-1)&*matrix(2,1,[100,70])); |
![matrix([[335/2], [615/4]])](images/m115-exf26.gif)
| > | evalf(%); |
![matrix([[167.5000000], [153.7500000]])](images/m115-exf27.gif)
So for this, we need 167.5 bushels of yams an 154 pigs.
Probability Section 2.4, page 88
Problem 12
First, the transition matrix:
| > | M:=matrix(3,3,[0,1/5,4/5,3/5,0,2/5,1/2,1/2,0]); |
![M := matrix([[0, 1/5, 4/5], [3/5, 0, 2/5], [1/2, 1/2, 0]])](images/m115-exf28.gif)
(b) To see what happens two times from now, we apply
:
| > | evalm(M^2&*matrix(3,1,[1/3,1/3,1/3])); |
![matrix([[1/3], [1/3], [1/3]])](images/m115-exf30.gif)
So if they were equally likely to have the ball at stage n, this will be true again at stage n+2.
(c) To find the stationary distribution, we calculate the kernel of M-I
| > | kernel(M-&*()); |
![]()
This indicates (as did part (b) if you think about it!) that in the long run the boys are equally likely to have the ball.
FINITE CHAPTER 3 - Linear programming (graphical)
Section 3.1, page 131
Problem 29
| > | with(plots,inequal): |
| > | inequal({2*y+x>=-5,y<=3+x,x>=0,y>=0},x=0..10,y=0..10,thickness=2); |
![[Maple Plot]](images/m115-exf32.gif)
The feasible region is in the first quadrant, below the diagonal line.
Section 3.2, page 138
Problem 9
First, let's plot the feasible region:
| > | inequal({3*x-y>=12,x+y<=15,x>=2,y>=5},x=0..10,y=0..10,thickness=2); |
![[Maple Plot]](images/m115-exf33.gif)
So we need to check the three corners:
| > | corner1:=solve({3*x-y=12,x+y=15}); |

| > | corner2:=solve({y=5,3*x-y=12}); |

| > | corner3:=solve({y=5,x+y=15}); |
![]()
| > | obj:=2*x+2*y; |
![]()
| > | subs(corner1,obj),subs(corner2,obj),subs(corner3,obj); |

| > | evalf([%]); |
![]()
So the maximum is 30, and this is attaned at both corner 1 and corner 3 (and thus along the whole segment between them, since the objective function has the same slope as this line).
Section 3.3, page 144
Problem 21
Say he takes x pill A's and y pill B's.
The constraints are:
Vitamin A: 8x+2y>=16 ; Vitamin B1: x+y>=5 ; Vitamin C: 2x +7y>=20
The cost is: 15x + 30y
| > | inequal({8*x+2*y>=16,x+y>=5,2*x+7*y>=20,x>=0,y>=0},x=0..10,y=0..10); |
![[Maple Plot]](images/m115-exf40.gif)
This time, there are four corners:
| > | corner1:=solve({x=0,8*x+2*y=16}); |
![]()
| > | corner2:=solve({8*x+2*y=16,x+y=5}); |
![]()
| > | corner3:=solve({x+y=5,2*x+7*y=20}); |
![]()
| > | corner4:=solve({2*x+7*y=20,y=0}); |
![]()
| > | obj:=15*x+30*y; |
![]()
| > | subs(corner1,obj),subs(corner2,obj),subs(corner3,obj),subs(corner4,obj); |
![]()
So the minimum is 105, at corner 3: he should take 3 Pill A's and 2 Pill B's each day.
FINITE CHAPTER 4 - The Simplex Method
Section 4.2, page 168
Problem 7
Maple has a simplex method built in:
| > | with(simplex): |
Warning, the names basis, display and pivot have been redefined
Warning, the protected names maximize and minimize have been redefined and unprotected
| > | obj:=4*x+3*y; constraints:={2*x+3*y<=11,x+2*y<=6,x>=0,y>=0}; |
![]()
![]()
| > | maximize(obj,constraints); |

| > | subs(%,obj); |
![]()