Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8512863
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T04:23:51+00:00 2026-06-11T04:23:51+00:00

I am calculating the inverse of a matrix using the adjoint method. first i

  • 0

I am calculating the inverse of a matrix using the adjoint method. first i have to calculate the determinant of the matrix. to calculate the determinant I first create an upper triangular matrix and then multiply the diagonals to get the determinant of the matrix. the fomular for calculating the determinant is given below.

for(int cr = 1 ;cr < dd.length;cr++)
{ double factor = 0.0;      
  final   double[] firstrow = new double[dd.length] ; /* dd is a matrix*/

  for(int r = 0 ;r < dd.length; r++)  
 { firstrow[r] = dd[cr - 1][r]; }

for( int rowcount = cr + 0 ; rowcount< dd.length ; rowcount++)
{           
  factor = dd[rowcount][cr - 1] / firstrow[cr - 1];

for( int m = cr - 1 ; m < firstrow.length ; m++)
{  
dd[cr - 1][m] = firstrow[m] * factor;               /* multioly row by factor */                                                
dd[rowcount][m] = dd[rowcount][m] - dd[cr - 1][m];  /* our current row minus factored row */
dd[cr - 1][m] = firstrow[m];                        /* restore the original values to row */    
}    }} 

for(int d = 0 ; d < dd.length;d++)
{det *= dd[d][d];}    /* det is the determinant */

after getting the lower triangular matrix , the product of the diagonal values becomes the determinant of the matrix. I have tried this method and it works. however when I use it to calculate the determinant of a 13 by 13 matrix with floating point values , I get a not a number value that is NaN as the determinant.
Can someone please explain to me what is happening.
I have below example values of the matrix.

65.15078176822551
 731.664756199619
 1.5309584518179011E9
 1.7388182254012366E11
 3.3604905770182707E17
 1.77135880331128576E17

thank all

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T04:23:52+00:00Added an answer on June 11, 2026 at 4:23 am

    I suspect that the problem is something to do with your use of factor to (I’m guessing) reduce the scale of the numbers. My bet is that firstrow[cr - 1] is zero for some index. The ensuing division by zero will create and INF or a NaN, and that will propagate through the rest of the calculation.


    Incidentally, this “formula” doesn’t look like the standard method for calculating determinants, as explained here:

    http://www.math.dartmouth.edu/archive/m8s00/public_html/handouts/matrices3/node7.html

    The standard version doesn’t involve any division. Are you sure that your “formula” is correct?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to calculate the inverse matrix in Java. I'm following the adjoint method
I am calculating the inverse of a square matrix using different libraries via Cholesky
I have algorithm of calculating average speed in pure python: speed = [...] avg_speed
I am calculating intersection, union and differences of sets. I have a typedef of
I am calculating percentages in Analysis Services 2008 using MDX by dividing the sum
I wanted to calculate the angle between two vectors but I have seen these
I’m calculating the inactive interval of a particular user using the following code: inActiveInterval
I have this calculating form works extremely well for my client up some one
I have been making a matrix class (as a learning exercise) and I have
I have a problem calculating the distance between two geopoints. The geopoints are: position1

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.