FAILURE MAP
← Case archive

FA-6021 / Linear algebra / Open access

Matrix trace · case 01

Every matrix entry is summed rather than only the diagonal.

Verified by executionVariant 1 · 4 checks per implementationDownload source bundle ↓JSON ↗

ROOT CAUSE

Every matrix entry is summed rather than only the diagonal.

VERIFIED REPAIR

Apply the specified mathematical contract directly, preserving all terms and boundary cases: return sum(m[i][i] for i in range(len(m)))

Unsuccessful approach: The antidiagonal is selected.

Case contract

Integer matrix/vector entries, rectangular rows, compatible multiplication dimensions, and square matrices for determinant, trace, inverse, symmetry and characteristic-polynomial operations. Rational matrix outputs are reduced Fraction strings. Matrix trace. Exact operational definition: sum(m[i][i] for i in range(len(m)))

Why this case matters

Small exact fixtures expose this error without platform timing, external services, or probabilistic observations. Linear algebra results depend on the stated convention.

1 / The failure

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import calendar
import statistics
import itertools
from fractions import Fraction
from datetime import date, datetime, timedelta, timezone
from decimal import Decimal, ROUND_HALF_UP, ROUND_DOWN, ROUND_CEILING, ROUND_FLOOR

N = 1
observations = []
def solve(m):
    return sum(map(sum,m))
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: ([[1, 2], [3, 4]],)', solve(*([[1, 2], [3, 4]],)), 5)
check('fixture 2: ([[1, 2, 3], [4, 5, 6], [7, 8, 10]],)', solve(*([[1, 2, 3], [4, 5, 6], [7, 8, 10]],)), 16)
check('fixture 3: ([],)', solve(*([],)), 0)
check('fixture 4: ([[7]],)', solve(*([[7]],)), 7)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
fixture 1: ([[1, 2], [3, 4]],)105Failed
fixture 2: ([[1, 2, 3], [4, 5, 6], [7, 8, 10]],)4616Failed
fixture 3: ([],)00Passed
fixture 4: ([[7]],)77Passed

SHA-256 / da7a1adbe23877dfb3f7f27a482992bd4ff1c05720e14c253c38519021064359

2 / The unsuccessful fix

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import calendar
import statistics
import itertools
from fractions import Fraction
from datetime import date, datetime, timedelta, timezone
from decimal import Decimal, ROUND_HALF_UP, ROUND_DOWN, ROUND_CEILING, ROUND_FLOOR

N = 1
observations = []
def solve(m):
    return sum(m[i][-i-1] for i in range(len(m)))
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: ([[1, 2], [3, 4]],)', solve(*([[1, 2], [3, 4]],)), 5)
check('fixture 2: ([[1, 2, 3], [4, 5, 6], [7, 8, 10]],)', solve(*([[1, 2, 3], [4, 5, 6], [7, 8, 10]],)), 16)
check('fixture 3: ([],)', solve(*([],)), 0)
check('fixture 4: ([[7]],)', solve(*([[7]],)), 7)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
fixture 1: ([[1, 2], [3, 4]],)55Passed
fixture 2: ([[1, 2, 3], [4, 5, 6], [7, 8, 10]],)1516Failed
fixture 3: ([],)00Passed
fixture 4: ([[7]],)77Passed

SHA-256 / daf3e94ececb3a719d1d0bdba5e84a88eaea434d299fe42e4cb31d5ce27e7d8b

3 / The verified repair

Exit 0
"""Failure Map reference implementation. Python standard library only."""
import json
import math
import calendar
import statistics
import itertools
from fractions import Fraction
from datetime import date, datetime, timedelta, timezone
from decimal import Decimal, ROUND_HALF_UP, ROUND_DOWN, ROUND_CEILING, ROUND_FLOOR

N = 1
observations = []
def solve(m):
    return sum(m[i][i] for i in range(len(m)))
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: ([[1, 2], [3, 4]],)', solve(*([[1, 2], [3, 4]],)), 5)
check('fixture 2: ([[1, 2, 3], [4, 5, 6], [7, 8, 10]],)', solve(*([[1, 2, 3], [4, 5, 6], [7, 8, 10]],)), 16)
check('fixture 3: ([],)', solve(*([],)), 0)
check('fixture 4: ([[7]],)', solve(*([[7]],)), 7)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
fixture 1: ([[1, 2], [3, 4]],)55Passed
fixture 2: ([[1, 2, 3], [4, 5, 6], [7, 8, 10]],)1616Passed
fixture 3: ([],)00Passed
fixture 4: ([[7]],)77Passed

SHA-256 / 7cd77e10e33868ef98ec1a1d7a3d64402330b6fbe3b928060698e8426cc5af46

Verification & scope

This reproducer isolates one failure mechanism. Results cover the supplied fixtures. Variants within a family share a test contract and should remain grouped when constructing evaluation splits. Related mechanisms with a shared evaluation_group must also remain together; these controlled models are not independent production incidents.

Observations recorded using Python 3.12.14 at 2026-09-29T14:37:56.487491+00:00.

Case digest / 40ca6bf3445024e5e844460e499ce920caa4323e5654380c70ccd01cc2090d9a