Ask Your Question
1

Determinants of Matrices with Symmetric Functions

asked 2019-09-06 08:45:01 -0500

I'm interested in calculating the determinant of the matrix $ A = (a_{i+j})$ for $0\leq i,j\leq n$ in which $a_{k} = \frac{h_k}{e_k}$ where $h_k, e_k$ are the homogeneous (elementary, resp.) symmetric functions of degree $k$. I would like to express the numerator of $\det(A)$ in terms of monomial symmetric functions.

I have written some code that I think does the job, but it seems an incredibly hacky way of doing it in my opinion. Since I am quite new to sage I was wondering whether someone might be able to take a look at what I've done and suggest a more sage-like way to tackle this problem? My code is below.

I define a set of functions:

# set up two matrices containing symbolic functions hh(i+j), ee(i+j), which are later replaced with symmetric functions h and e

def heMatrices(N):
    hh = function('hh')
    ee = function('ee')
    H = matrix(SR,N,N,lambda i,j:hh(i+j))
    E = matrix(SR,N,N,lambda i,j:ee(i+j))
    return H,E

# Pointwise divides two matrices (a bit like Hadamard division??)

def elementwiseDivision( M, N ):

    assert( M.parent() == N.parent() )

    nc, nr = M.ncols(), M.nrows()
    A = copy( M.parent().zero() )

    for r in range(nr):
        for c in range(nc):
            A[r,c] = M[r,c] / N[r,c]

    return A

# extracts numerator of determinant

def extractNumerator(M):
    return det(M).numerator()

# extracts denominator of determinant
def extractDenominator(M):
    return det(M).denominator()

# This is dodgy - treates expression as a python string and replaces e(x) with e[x], h(x) with h[x]

def convertToSymmetricString(expr):
    st = str(expr)
    st = st.replace('(','[')
    st = st.replace(')',']')
    st = st.replace('ee','e')
    st = st.replace('hh','h')
    return st

# Puts together the above functions.

def evaluateDeterminant(N):
    h,e = heMatrices(N)
    A = elementwiseDivision(h,e)
    srExpression = extractNumerator(A)
    sageExpression = convertToSymmetricString(srExpression)
    return sageExpression

Then I open sage in the command line and type the following:

sage: Sym = SymmetricFunctions(QQ)                                       
sage: Sym.inject_shorthands(verbose=False)
sage: ee = evaluateDeterminant(2)
sage: ans = sage_eval(ee, locals=vars())
sage: ans = m(ans)

which returns

2*m[2, 1, 1] + 2*m[2, 2] + 2*m[3, 1] + m[4]

which I believe is what I'm after.

edit retag flag offensive close merge delete

1 answer

Sort by » oldest newest most voted
1

answered 2019-09-08 12:44:28 -0500

rburing gravatar image

updated 2019-09-12 07:48:28 -0500

Yeah that's quite hacky. Try this instead:

N = 2
R = PolynomialRing(QQ, names=['h_{}'.format(k) for k in range(2*N)] + ['e_{}'.format(k) for k in range(2*N)])
H = R.gens()[0:2*N]
E = R.gens()[2*N:]
M = Matrix(R.fraction_field(), N, lambda i, j: H[i+j]/E[i+j])
Sym = SymmetricFunctions(QQ)
e = Sym.elementary()
h = Sym.homogeneous()
m = Sym.monomial()
he_subs = dict(zip(R.gens(), [h[k] for k in range(2*N)] + [e[k] for k in range(2*N)]))
print(m(M.det().numerator().subs(he_subs)))

A symbolic alternative (basically, a cleaner version of what you did):

N = 4
Sym = SymmetricFunctions(QQ)
e = Sym.elementary()
h = Sym.homogeneous()
m = Sym.monomial()
H = function('H', nargs=1, print_func=lambda self, *args: 'h[{}]'.format(args[0]))
E = function('E', nargs=1, print_func=lambda self, *args: 'e[{}]'.format(args[0]))
M = Matrix(SR, N, lambda i, j: H(i+j)/E(i+j))
print(m(sage_eval(str(M.det().numerator()), locals={'h': h, 'e': e})))
edit flag offensive delete link more

Comments

Please use python3 syntax in your answers.

FrédéricC gravatar imageFrédéricC ( 2019-09-08 13:35:04 -0500 )edit

Many thanks! Interestingly it seems as though for n = 4 your solution takes an age to finish computing whereas my original solution returns an answer within around 90 minutes (on my not-very-good computer). I'm not sure how much I can really trust my answer though.

WubbaLubbaDubDub gravatar imageWubbaLubbaDubDub ( 2019-09-09 05:13:23 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2019-09-06 04:24:50 -0500

Seen: 49 times

Last updated: Sep 12