(can't post multiline code in comments)
What should it compute? Here's a mathematically nonsensical example (I hope I captured the general idea of your question):
n = 4 # even dimension MS = MatrixSpace(SR,n,n) # define the matrix space # Define the 2D list (a list of lists) that's about to become # a matrix with named variables (matrices in SageMath are immutable): ml = [ [0]*n for i in range(n)] # Generate the named variables and add them to the list in the usual order: for i in range(n): # 0...n-1 for j in range(n): # This injects the variable name into the SR: ml[i][j] = var('m'+str(i)+str(j)) M = MS(ml) # make the 2D list a matrix # Generate the vector (0,1,2,...,n-1): v = VectorSpace(SR,n)(list(range(n))) # The function. def f(m, t): # Split the vector in half: v0 = t[:n//2]; v1 = t[n//2:] # Split the matrix into 4 blocks: m.subdivide([n//2], [n//2]) # Take the lower two ones: C = m.subdivision(1,0); D = m.subdivision(1,1) # Multiply the half-vectors by inverses of half-matrices, # reconstruct the long vector and operate upon it too: return m*vector(list(C^-1*v0) + list(D^-1*v1)) f(M,v) # evaluate the example
Please ask any questions on notation, or post the formula you want to adjust the above computation to.
vars = var('x11 x12 x21 x22')(using loops to build the string with variable names), then operate inMatrixSpace(SR,m,n)= $m\times n$ matrix ring over the 'symbolic ring' (it includes all variables you defined). What kind of function do you want? $\endgroup$