Results 1 to 3 of 3

Thread: Linear Programming Question

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Apr 2002
    Location
    San Diego, California
    Posts
    67

    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
    Last edited by Cornflake; Jul 4th, 2005 at 09:24 PM.
    I wuv VB

  2. #2
    Only Slightly Obsessive jemidiah's Avatar
    Join Date
    Apr 2002
    Posts
    2,431

    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.

    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!
    The time you enjoy wasting is not wasted time.
    Bertrand Russell

    <- Remember to rate posts you find helpful.

  3. #3
    Frenzied Member yrwyddfa's Avatar
    Join Date
    Aug 2001
    Location
    England
    Posts
    1,253

    Re: Linear Programming Question

    VB Code:
    1. Public Sub MxGaussJordan(Matrix() As Double)
    2.    
    3.     Dim Rows As Long
    4.     Dim Cols As Long
    5.     Dim P As Long
    6.     Dim i As Long
    7.     Dim j As Long
    8.     Dim m As Double
    9.     Dim d As Double
    10.     Dim Pivot As Double
    11.    
    12.     Rows = UBound(Matrix, 1)
    13.     Cols = UBound(Matrix, 2)
    14.  
    15.     ' Reduce so we get the leading diagonal
    16.     For P = 0 To Rows
    17.         Pivot = Matrix(P, P)
    18.         For i = 0 To Rows
    19.             If Not P = i Then
    20.                 m = Matrix(i, P) / Pivot
    21.                 For j = 0 To Cols
    22.                     Matrix(i, j) = Matrix(i, j) + (Matrix(P, j) * -m)
    23.                 Next
    24.             End If
    25.         Next
    26.     Next
    27.    
    28.     'Divide through to get the identity matrix
    29.     'Note: the identity matrix may have very small values (close to zero)
    30.     'because of the way floating points are stored.
    31.     For i = 0 To Rows
    32.         d = Matrix(i, i)
    33.         For j = 0 To Cols
    34.             Matrix(i, j) = Matrix(i, j) / d
    35.         Next
    36.     Next
    37.    
    38. End Sub

    http://www.vbforums.com/showthread.php?t=311225
    "As far as the laws of mathematics refer to reality, they are not certain; and as far as they are certain, they do not refer to reality." - Albert Einstein

    It's turtles! And it's all the way down

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width