TheAlgorithms/Python · error · ValueError

No solution. (Inconsistent system)

Error message

No solution. (Inconsistent system)

What it means

Error "No solution. (Inconsistent system)" thrown in TheAlgorithms/Python.

Source

Thrown at matrix/cramers_rule_2x2.py:75

        raise ValueError("Please enter a valid equation.")
    if equation1[0] == equation1[1] == equation2[0] == equation2[1] == 0:
        raise ValueError("Both a & b of two equations can't be zero.")

    # Extract the coefficients
    a1, b1, c1 = equation1
    a2, b2, c2 = equation2

    # Calculate the determinants of the matrices
    determinant = a1 * b2 - a2 * b1
    determinant_x = c1 * b2 - c2 * b1
    determinant_y = a1 * c2 - a2 * c1

    # Check if the system of linear equations has a solution (using Cramer's rule)
    if determinant == 0:
        if determinant_x == determinant_y == 0:
            raise ValueError("Infinite solutions. (Consistent system)")
        else:
            raise ValueError("No solution. (Inconsistent system)")
    elif determinant_x == determinant_y == 0:
        # Trivial solution (Inconsistent system)
        return (0.0, 0.0)
    else:
        x = determinant_x / determinant
        y = determinant_y / determinant
        # Non-Trivial Solution (Consistent system)
        return (x, y)

View on GitHub (pinned to f5988cc097)

Solutions

  1. The system is inconsistent; check the equations for contradictory constraints.

When it happens

Trigger: Thrown at matrix/cramers_rule_2x2.py:75 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of TheAlgorithms/Python@f5988cc097 (2026-08-14). Data as JSON: /api/errors/962029b66d94a888. Report an issue: GitHub.