{"record":{"id":"b838f0b4df3e5d59","repo":"TheAlgorithms/Python","slug":"both-a-b-of-two-equations-can-t-be-zero","errorCode":null,"errorMessage":"Both a & b of two equations can't be zero.","messagePattern":"Both a & b of two equations can't be zero\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"matrix/cramers_rule_2x2.py","lineNumber":59,"sourceCode":"    >>> cramers_rule_2x2([0, 0, 6], [0, 0, 3])\n    Traceback (most recent call last):\n        ...\n    ValueError: Both a & b of two equations can't be zero.\n    >>> cramers_rule_2x2([1, 2, 3], [1, 2, 3])\n    Traceback (most recent call last):\n        ...\n    ValueError: Infinite solutions. (Consistent system)\n    >>> cramers_rule_2x2([0, 4, 50], [0, 3, 99])\n    Traceback (most recent call last):\n        ...\n    ValueError: No solution. (Inconsistent system)\n    \"\"\"\n\n    # Check if the input is valid\n    if not len(equation1) == len(equation2) == 3:\n        raise ValueError(\"Please enter a valid equation.\")\n    if equation1[0] == equation1[1] == equation2[0] == equation2[1] == 0:\n        raise ValueError(\"Both a & b of two equations can't be zero.\")\n\n    # Extract the coefficients\n    a1, b1, c1 = equation1\n    a2, b2, c2 = equation2\n\n    # Calculate the determinants of the matrices\n    determinant = a1 * b2 - a2 * b1\n    determinant_x = c1 * b2 - c2 * b1\n    determinant_y = a1 * c2 - a2 * c1\n\n    # Check if the system of linear equations has a solution (using Cramer's rule)\n    if determinant == 0:\n        if determinant_x == determinant_y == 0:\n            raise ValueError(\"Infinite solutions. (Consistent system)\")\n        else:\n            raise ValueError(\"No solution. (Inconsistent system)\")\n    elif determinant_x == determinant_y == 0:\n        # Trivial solution (Inconsistent system)","sourceCodeStart":41,"sourceCodeEnd":77,"githubUrl":"https://github.com/TheAlgorithms/Python/blob/f5988cc09713315817df6a7e327e258013a94440/matrix/cramers_rule_2x2.py#L41-L77","documentation":"Error \"Both a & b of two equations can't be zero.\" thrown in TheAlgorithms/Python.","triggerScenarios":"Thrown at matrix/cramers_rule_2x2.py:59 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Provide equations where at least one of a or b is non-zero in each equation."],"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-15T22:17:37.221Z"}