SSpectrumGorse
Product

Product features · Integer characteristic polynomials

01

SpectrumGorse provides a code-review setting for matrix characteristic coefficients, checking determinant identities without promising numeric eigenvalue estimates.

01

Connection

Base URL, credentials and a reachable server.

02

Selection

A model available through the configured endpoint.

03

Capabilities

Context limits and tool support are determined by the model and server.

Integer characteristic polynomials

● ● ●SpectrumGorse●
A concrete starting point · Integer characteristic polynomials ×
def characteristic_polynomial(matrix):
    if type(matrix) not in (list, tuple) or len(matrix) > 6:
        raise ValueError("charpoly.size")
    n = len(matrix)
    if any(type(row) not in (list, tuple) or len(row) != n or any(type(v) is not int or abs(v) > 1000 for v in row) for row in matrix):
        raise ValueError("charpoly.entry")
    block = [[int(i == j) for j in range(n)] for i in range(n)]
    coefficients = [1]
    for degree in range(1, n+1):
        product = [[sum(matrix[i][k]*block[k][j] for k in range(n)) for j in range(n)] for i in range(n)]
        trace = sum(product[i][i] for i in range(n))
        coefficient = -trace // degree
        coefficients.append(coefficient)
        block = [[product[i][j] + (coefficient if i == j else 0) for j in range(n)] for i in range(n)]
    return coefficients
✳Return descending coefficients of det(xI−A) for a square integer matrix of order zero through six with entries bounded by 1000 in magnitude.
✓ ChangesReview before applying ↗
Illustrative workspace
AI coding workspace

Your next change starts here.

Get the Windows app ↗