title: Allowing for deviations in exact values during matrix multiplication, python
body: <p>I need to solve this:</p>
  
  <p>Check if <code>AT * n * A = n</code>, where A is the test matrix, AT is the transposed test matrix  and n = <code>[[1,0,0,0],[0,-1,0,0],[0,0,-1,0],[0,0,0,-1]]</code>.</p>
  
  <p>I don't know how to check for equality due to the numerical errors in the float multiplication. How do I go about doing this?</p>
  
  <p>Current code:</p>
  
  <pre><code>def trans(A):
   n = numpy.matrix([[1,0,0,0],[0,-1,0,0],[0,0,-1,0],[0,0,0,-1]])
   c = numpy.matrix.transpose(A) * n * numpy.matrix(A)
  </code></pre>
  
  <p>Have then tried</p>
  
  <pre><code>&gt;if c == n:
       return True
  </code></pre>
  
  <p>I have also tried assigning variables to every element of matrix and then checking that each variable is within certain limits.</p>