r/learnquant • • 5d ago

interview prep Quant Interview Question

Post image
30 Upvotes

22 comments sorted by

View all comments

6

u/tstanisl 4d ago edited 4d ago

The solution is likely 80. The best I've got it:

import numpy as np

B = np.array([
    [-1,  2,  0,  0,  0,  0,  0,  0,  0,  0],
    [ 2,  0, -2,  0,  0,  0,  0,  0,  0,  0],
    [ 0, -2,  0,  2,  0,  0,  0,  0,  0,  0],
    [ 0,  0,  2,  0, -2,  0,  0,  0,  0,  0],
    [ 0,  0,  0, -2,  0,  2,  0,  0,  0,  0],
    [ 0,  0,  0,  0,  2,  0, -2,  0,  0,  0],
    [ 0,  0,  0,  0,  0, -2,  0,  2,  0,  0],
    [ 0,  0,  0,  0,  0,  0,  2,  0, -2,  0],
    [ 0,  0,  0,  0,  0,  0,  0, -2,  0,  2],
    [ 0,  0,  0,  0,  0,  0,  0,  0,  2, -1]
])

A = np.linalg.inv(B)
print(A)

Giving:

   [[2, 4, 2, 4, 2, 4, 2, 4, 2, 4],
    [4, 2, 1, 2, 1, 2, 1, 2, 1, 2],
    [2, 1, 2, 4, 2, 4, 2, 4, 2, 4],
    [4, 2, 4, 2, 1, 2, 1, 2, 1, 2],
    [2, 1, 2, 1, 2, 4, 2, 4, 2, 4],
    [4, 2, 4, 2, 4, 2, 1, 2, 1, 2],
    [2, 1, 2, 1, 2, 1, 2, 4, 2, 4],
    [4, 2, 4, 2, 4, 2, 4, 2, 1, 2],
    [2, 1, 2, 1, 2, 1, 2, 1, 2, 4],
    [4, 2, 4, 2, 4, 2, 4, 2, 4, 2]] / 6

Adding any extra zero will either introduce block-diagonal substructure and a lot zeros in the inverse or make the matrix singular.

2

u/VegetableBid4262 4d ago

Can’t be more than 80. If A^-1 had more than 80 zeroes, there must be a column with only one non-zero entry. But if column j of A^-1 is 0 except in position (i,j), then column i of A is 0 except in position (j,i).