title: How do calculate a determinant of an large matrix without getting an overflow?
body: <p>Good morning!</p>
  
  <p>I have an nxn-Matrix with n large enough to give me an overflow.</p>
  
  <p>I tried to fix this problem the mathematical way and it worked for small n but now I get an overflow from the Exponent.</p>
  
  <p>To explain it better here the code:</p>
  
  <pre class="lang-py prettyprint-override"><code>    # create a quadratic Matrix matrix with shape 500x500
      matrix = [[ 1.03796037 -0.00898546 -0.00410423 ... -0.0453022   0.02608995
        -0.01146299]
       ...
  
       [-0.01146299 -0.04572196  0.07370042 ...  0.03203931  0.07298667
         0.98693473]]
  
      # calculate the mean of matrix
      mean = matrix.mean()
      # calculate n
      n = matrix.shape[0]
      # divide the mean from the matrix and calculate the determinant 
      determinant = np.linalg.det(matrix/mean)
      # use now det(c*M) = c^n*det(M)
      solution = mean**n*determinant
  
      &gt;&gt;&gt;&gt; inf
  </code></pre>
  
  <p>This method works to prevent the overflow from the <code>np.linalg.det()</code> function but the calculation of the power <code>mean**n</code> gives an overflow and I have no idea how to solve this. The mean is btw a float and n a int
  Can you help here? Please only in Python or numpy.</p>