Linear Programming Question
Got a test in the morning, and I need help. I found something really similar to what we will be doing, if you could take the time to help me find the constraint/equations, I would greatly appreciate it.
Question:
Jane has $50,000 invested in three types of accounts yielding a total of $4,250 interest per year. She has twice as much invested at 9% as at 8% and the rest at 7%. Set up an augmented matrix for the system and use Gauss-Jordan elimination to find the amount invested in each type of account.
So far all I have setup it that x1=9%, x2=8%, x3=7%
Thanks in advance.
EDIT: Changed the problem because I solved the other one :)
Re: Linear Programming Question
Matrices are seldom covered in most math classes, so I thought I'd look this one up :)
From what I found online, you seems to have to make a system of equations first.
Quote:
Jane has $50,000 invested in three types of accounts yielding a total of $4,250 interest per year. She has twice as much invested at 9% as at 8% and the rest at 7%. Set up an augmented matrix for the system and use Gauss-Jordan elimination to find the amount invested in each type of account.
Ok, we want to find how much money is invested in three different accounts. So, we need to use three variables in this particular system. Let's say X is the first account at 9%, and so on for Y and Z.
So, the three truths we need to pick out are:
1: X + Y + Z = 50,000. The total money in all three accounts is $50,000.
2: 0.09X + 0.08Y + 0.07Z = 4,250. The total interest on the three accounts is $4,250 per year, so find the simple interest on all three and add them.
3: X = 2Y, because there is twice as much at 9% than as at 8%. To make this usable, say that X - 2Y = 0, and then that X - 2Y + 0Z = 0. :)
Now, put in augmented matrix form: (I have no idea how to put this in a matrix here, so I'll do my best)
[1.00 1.00 1.00|50,000]
[0.09 0.08 0.07|4,250]
[1.00 -2.0 0.00|0.0000]
Ok, now we need to make this a "diagonal coefficient" matrix, with zeros everywhere but the diagonal. This, in my opinion, is the really junky part. Sadly, it would take me about an hour to type out explicitly all the steps, so I'll just say them.
First, take the second row and multiply it by 100. Then, subtract from that 7 * the first row, (1 1 1 | 50,000).
Now, take the third row and multiply it by -1. Then, add the first row to what you have now for the third row [add (1 1 1 | 50,000)].
Now, take the first row and subtract what you currently have for the second row from it [subtract (2 1 0 | 75,000)].
Continuing, take the second row and subtract twice the original third row [subtract 2 * (1 -2 0 | 0)].
Ok, you should have this if I have typed everything right:
[-1 0 1|-25,000]
[+0 5 0|75,000]
[0 3 1|50,000]
Now, from row three, subtract 3/5 * your current row 2 [subtract 3/5 * (0 5 0|75,000)].
Then, take row one and add 1/5 * the current row 2 [add 1/5 * (0 5 0|75,000)].
Finally, you should have a diagonal matrix like this:
[-2 0 0|-60,000]
[+0 5 0|75,000]
[+0 0 1|5,000]
I have tested this portion in an automatic equation solver, and it is correct, luckily.
Now, we need an identity matrix, with all ones in the diagonals and zero's everywhere else. To do this, simply divide each of the three rows by the coefficient remaining:
From row 1, divide the entire row by -2. From row 2, divide the entire row by 5. From row 3, divide the entire row by 1. Finally, we have this identity matrix:
[1 0 0|30,000]
[0 1 0|15,000]
[0 0 1|5,000]
From here, the solution is simply the right-hand side of the augmented matrix. This means that X = 30,000; Y = 15,000; and Z = 5,000. This makes sense, and is the solution (finally ;)).
Now, you might have been taught some different and hopefully easier way, but this is the way the website I found said to do it (http://ceee.rice.edu/Books/CS/chapter2/linear44.html). Anyway, good luck on the test if it's still coming!
Re: Linear Programming Question
VB Code:
Public Sub MxGaussJordan(Matrix() As Double)
Dim Rows As Long
Dim Cols As Long
Dim P As Long
Dim i As Long
Dim j As Long
Dim m As Double
Dim d As Double
Dim Pivot As Double
Rows = UBound(Matrix, 1)
Cols = UBound(Matrix, 2)
' Reduce so we get the leading diagonal
For P = 0 To Rows
Pivot = Matrix(P, P)
For i = 0 To Rows
If Not P = i Then
m = Matrix(i, P) / Pivot
For j = 0 To Cols
Matrix(i, j) = Matrix(i, j) + (Matrix(P, j) * -m)
Next
End If
Next
Next
'Divide through to get the identity matrix
'Note: the identity matrix may have very small values (close to zero)
'because of the way floating points are stored.
For i = 0 To Rows
d = Matrix(i, i)
For j = 0 To Cols
Matrix(i, j) = Matrix(i, j) / d
Next
Next
End Sub
http://www.vbforums.com/showthread.php?t=311225