{"record":{"id":"3646f6ead3550d74","repo":"TheAlgorithms/Python","slug":"please-provide-a-matrix-of-size-2x2-or-3x3","errorCode":null,"errorMessage":"Please provide a matrix of size 2x2 or 3x3.","messagePattern":"Please provide a matrix of size 2x2 or 3x3\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"matrix/inverse_of_matrix.py","lineNumber":155,"sourceCode":"        cofactor_matrix[2][2] = (d(matrix[0][0]) * d(matrix[1][1])) - (\r\n            d(matrix[0][1]) * d(matrix[1][0])\r\n        )\r\n\r\n        # Transpose the cofactor matrix (Adjoint matrix)\r\n        adjoint_matrix = array(cofactor_matrix)\r\n        for i in range(3):\r\n            for j in range(3):\r\n                adjoint_matrix[i][j] = cofactor_matrix[j][i]\r\n\r\n        # Inverse of the matrix using the formula (1/determinant) * adjoint matrix\r\n        inverse_matrix = array(cofactor_matrix)\r\n        for i in range(3):\r\n            for j in range(3):\r\n                inverse_matrix[i][j] /= d(determinant)\r\n\r\n        # Calculate the inverse of the matrix\r\n        return [[float(d(n)) or 0.0 for n in row] for row in inverse_matrix]\r\n    raise ValueError(\"Please provide a matrix of size 2x2 or 3x3.\")\r\n","sourceCodeStart":137,"sourceCodeEnd":156,"githubUrl":"https://github.com/TheAlgorithms/Python/blob/f5988cc09713315817df6a7e327e258013a94440/matrix/inverse_of_matrix.py#L137-L156","documentation":"Error \"Please provide a matrix of size 2x2 or 3x3.\" thrown in TheAlgorithms/Python.","triggerScenarios":"Thrown at matrix/inverse_of_matrix.py:155 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass a square matrix of size 2x2 or 3x3."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"f5988cc09713315817df6a7e327e258013a94440","analyzedAt":"2026-08-14T17:30:07.041Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}