Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Find Determinant/or Row Reduce parameter dependent matrix

  1. Jun 27, 2012 #1
    I'm trying to find the determinant of a band diagonal matrix that has a parameter, κ, in some of the entries. Some entries are just numerical ones, others (κ X number), while others are (κ + number). I have been told that they way to solve for κ is to find the determinant of the this matrix and then find values of κ that make the determinant zero.

    The main issue I'm having is that when my matrix becomes large the determinant just results to zero,and in other cases to calculation overflow. (I'm trying to work out all the bugs in the code, so det =0, might be some error I'm making, but the overflow error is not avoidable).

    I have already tried an LUDecomposition on the matrix, and that seems to take forever, I don't have a problem waiting, but working out the scaling, it seemed like I would have to wait a couple of days for a 500X500 matrix, and my real problem might have to be done on a 1000X1000 matrix.

    I was also thinking that maybe I could somehow get the matrix into an upper triangular form and then just multiple the diagonal elements. For this I tried using Mathematica's RowReduce command, but for some weird reason that just results in the identity matrix. I thought that row reduce might give me an upper triangular matrix with f(κ) on the diagonal , and I could just multiple the diagonal elements and get a polynomial for κ and solve.

    Any and all help is greatly appreciated. I'm not really sure how to put up my code, or the matrix for that matter. That is the thing that would probably help you guys the most. If there is a way for me to put up the matrix please let me know.

    Thanks again.
  2. jcsd
  3. Jun 27, 2012 #2
    Start with a 10x10 or 20x20 matrix that is very similar to what your full scale matrix will be like. Make the diagonals like you expect, the size of numbers like what you expect, with or without decimal points like you expect, etc.

    Put that matrix in a notebook with the simplest clearest best example of your code that you can come up with. Attach that notebook to your next post with clear specific questions about what you need help with. That will give you the best chance of getting a correct useful answer.

    Then when you are sure everything is as correct as it is going to be you can scale it up to gigabytes and months to complete
  4. Jun 27, 2012 #3
    Hey Bill,

    Thanks for the post. I've attached a Mathematica file, with a 10X10 matrix, that has the essence of my matrix.


    Attached Files:

  5. Jun 28, 2012 #4
    Thank you. This makes the question much more concrete.

    In[2]:= Det[t2]

    Out[2]= 2.2272666733337655*^26 + 9.645234733908778*^26*κ +
    4.371330048350632*^27*κ^2 + 8.861942706420684*^25*κ^3 -
    2.239345794822683*^25*κ^4 - 3.605118272791786*^24*κ^5 -
    2.6482517171741852*^22*κ^6 - 3.8768184082651635*^17*κ^7

    In[3]:= Solve[Det[t2]==0,κ]

    Out[3]= {{κ -> -68173.53229501807}, {κ -> -129.73732341256942},
    {κ -> -7.963334721970968 - 8.383566010522163*I},
    {κ -> -7.963334721970968 + 8.383566010522163*I},
    {κ -> -0.11026869176116452 - 0.19753775539064541*I},
    {κ -> -0.11026869176116452 + 0.19753775539064541*I},
    {κ -> 9.49259645600023}}

    So you have a combination of moderately large coefficients, up to +/-1000 or so along with high degrees of k in your determinant.

    When you want 1000x1000 matricies like this the coefficients in your determinant are going to be stunning.

    Now for the larger matricies you have tried, is the determinant becoming zero because you just have enough zero entries? Or does it look like this is because of accumulated error in the determinant calculation?

    You might be able to answer that by writing a little code to check each of the diagonals to see if there is a zero somewhere in every one of them. That might be done with some nested For loops and subscripting to extract individual entries to test against zero. If there is a zero in every diagonal then you may need to think about what it means to have a zero polynomial for your problem.

    If the problem seems to be mostly overflow of the exponent in the calculation of the determinant you might wonder whether your matrix can be conditioned in some way to avoid the overflow.


    Solve[Det[t2/1000.] == 0, κ]

    won't change the solutions but it will dramatically decrease the size of the coefficients in the polynomial. But I'm not at all certain this is what you want.

    What are the bugs you think you are falling into?

    What is the code you want to use on this matrix?
  6. Jun 28, 2012 #5
    Hi Bill,

    Thanks again for the help. I did basically try what you put up, i.e. using Solve to find the values of κ, and had success for small matrices. But after I increased the grid size the coefficients get out of control, and eventually I get an overflow error, or just zero determinant. And as I said earlier I'm pretty sure the zero is happening because of the craziness of the coefficients.

    I have also thought about trying this: Solve[Det[t2/1000.] == 0, κ], and it did seem to help, but I guess one thing that's hard to notice with the examples I have is that my real matrix has plenty of small numbers as well, and in fact I run into an underflow problem.

    Indeed I think I need to go back to the equations that lead up the matrix and see if can write down the problem a different way. I've posted this problem in a different forum, where they are suggesting that I use a Singular Value Decomposition of the matrix, and then apply a root-finder to that. That forum is here if you are interested:


    Thanks again.
  7. Jun 28, 2012 #6
    Hey Bill,

    Just wondering if you had any suggestions for my issues with RowReduce. If you try RowReduce[t2] you should see what I mean. How come κ is totally removed from the matrix?
    Is there any code out there where I can just implement RowReduce without actually using the function, I don't really need the matrix in row-echelon form, just upper triangular will do.

  8. Jun 28, 2012 #7
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook