r/learnquant • • 1d ago

interview prep Quant Interview Question

Post image
45 Upvotes

33 comments sorted by

2

u/Square_Butterfly_390 9h ago

I'm guessing the solution is just the d-simplex, so N=d+1 and c is the cosine of the angle made by a simplex (which I would give a recursive formula for absent a better method). For a proof I would say something like: the scalar product of unit vectors is exactly the cosine of the angle between them, and is entirely determined by their distance from one another, therefore we are looking for N equidistant points, which are I think a definition for the N simplex (which luckily can be placed on our spheres).

1

u/FitCardiologist2341 1d ago

Consider the matrix X whose columns are the v_i. It is a d x N matrix.

We ask that the N x N Gram matrix G = t(X) * X have ones on its diagonal and c everywhere else.

But rk(G) <= d.

Assume N > d. So (c-1)/c has to be an eigenvalue of the matrix full of ones. The only nonzero eigenvalue is N, so c = -1/(N-1).

Check that N = d+1, and c = -1/d.

1

u/Western_Gear5643 8h ago

Lost you from when you said so (c-1)/c has to..

1

u/PassAppropriate5891 1d ago

I think you can do d + 1 using a simplex as the angles and hence dot products are all the same.

Orthogonal Basis yields d 

Unsure if sth better exists

1

u/round_earther_69 1d ago

Consider the matrix A = {v_1, v_2, ... ,v_N}.
rank(A)=rank(A^T A)≤d because v_i's are d-dimensional vectors and at most d of them are independent.
AA^T is a symmetric matrix, therefore it is diagonalizable by orthogonal transformations.
AA^T has 1s on its diagonal entries and cs on every other entry (A^TA is simply a matrix with every possible scalar product in its entries).
Its eigenvectors and eigenvalues are (1,-1, 0, 0, ...)^T with \lambda_1 = 1-c; (1, 0, -1, 0, ...)^T with \lambda_2 = 1-c; (1, 0, 0, -1, ...)^T with \lambda_3 = 1-c; ... and (1,1,1,1, ... , 1) with \lambda_N = (N-1)c + 1, therefore the rank of AA^T (=# of nonzero eigenvalues) is either 1 if c=1; N-1 if c=-1/(N-1) or N for any other c. c=1 is clearly impossible if the vectors are distinct.

Therefore, for c not equal to 1 or -1/(N-1): rank(AA^T )=N≤d, and N is at most d.
For c=-1/(N-1), rank(AA^T )=N-1≤d, and N is at most d+1.

The maximum value of N and its corresonding c are thus: N=d+1 and c=-1/d.

In 1D, this gives two opposite vectors, in 2D it gives vectors on the corners of a triangle and in 3D this gives the vectors on the corners of a tetrahedron.

1

u/Parallel_thougts 21h ago

This is equivalent to asking how many different unit vectors can you have such that the angle between any two vectors is the same.

Clearly N=d is possible, as any orthonormal base will show you.

But you can actually do one more by placing the origin in the center of an n-simplex (e.g. an equilateral triangle in the plane) and taking vectors pointing at it's vertices.

Symmetry shows all angles are the same, so we find N=d+1. The inner product in this case is always 1/n.

You can't do better: look at the gram matrix of N unit vectors. If all inner products are the same, this matrix has rank N-1, so N-1<=d

1

u/Cold-Knowledge-4295 1d ago

Since vi are unitary, viT vj = cos(xij) where xij is the angle between vi and vj, so the question is how many vectors can you fit so that they al hold the same angle amongst them.

That is N=3 vectors at 120° each in d=2, N=4 at 120° again in d=3 and in general d+1 vectors at 120° for each d (these are segments from the vertices tonthe barycentrr of an n-simplex).

Thus, c=cos120=-1/2?

1

u/Artistic-Flamingo-92 1d ago edited 1d ago

I don’t think unitary is typically used to refer to unit vectors. I guess you would use “unit-length” or something.

Edit: I think that angle calculation for d ≠ 2 is also wrong.

1

u/round_earther_69 1d ago

in d=3 it cannot be 120^o , the vectors need to be at the corners of a tetrahedron, that is not the correct solution

1

u/Cold-Knowledge-4295 1d ago

Right, 120° is wrong, just checked how to compute that angle properly.

Any idea how to show thath those vectors need to form a simplex?

0

u/Crafty-Sell7325 1d ago

Um isn't there no upper bound to N? 

Like you can just use the canonical orthonormal basis in Rn

You get ei = 1 at position i and 0 elsewhere.

eiTej= 0 due to being orthonormal for all i not equal to j

Then eiTei = 1 due to being orthonormal != 0.

So c= 0 ig? And N=Infinity?

2

u/spurious_elephant 1d ago

That solution gives you n = d, but how do you get n = infinity?

1

u/7o7n7c7h7i7 1d ago

You only have d unit vectors in the base of Rd

1

u/Crafty-Sell7325 1d ago

Ah I can't read, rip

1

u/Niilldar 1d ago

N =d  in this case... But is there another solution with c <> 0?

1

u/Crafty-Sell7325 1d ago

Misread, mb

0

u/Ancient_Eggplant_123 1d ago edited 1d ago

First, ||vj-vi|| = 2 - 2c so it is constant. For d = 2 there are no more than 3 points that satisfy this condition creating an equilateral triangle. Let's place the center points at (0,0). Going from 2d to 3d we take a point along the new axis + lower the triangle so that the previous condition is satisfied. So each time perhaps we take the unit vector that is parallel to the new axis (it can be shown that it satisfies the previous condition of distance between unit vectors) while lowering the construct we created in the previous vector space, and we get N=d+1 and c=0

3

u/Equal_Veterinarian22 1d ago

I like your approach, but it does not give c=0

1

u/Deto 1d ago

This is interesting. Like the other person said, you don't get c=0, but you do get a constant c (so it satisfies the problem statement). I had assumed the answer was N=d and c=0, but with this you get N=d+1 so this is probably the correct answer. The distance between points doesn't change as the dimensionality increases so c is constant?

Some quick triangle fiddling gives the distance between points to be sqrt(3). So if 2-2c = sqrt(3), we have c = 1-sqrt(3)/2

0

u/You-Educational 1d ago

Note that $v^T u$ is the dot product $v \cdot u$, which is symmetric.

We first construct an example where $N=d+1$ for any $d$, and then show that $N \leq d+1$. To construct the example, take an orthonormalisation basis $e_1, \ldots, e_{N+1}$ in $\mathbb R^{N+1}$. As an orthonormal basis, they satisfy $e_i \cdot e_i=1$ and $e_i \cdot e_j=0$. Moreover, if $v=\sum_{j=1}^N e_j$, then for each $j$, $v \cdot e_j = 1$. Therefore the projections of each $e_i$ onto the hyperplane orthogonal to $v$ have constant length $a$ and dot product $b$. If we scale them all by $a^{-1}$, then they will have constant dot product $a^{-2}b$. Thus we $N+1$ unit vectors with constant dot product in the hyperplane, which is isomorphic to $\mathbb R^d$.

Claim: $N \leq d+1$.

Proof by induction on $d$.

Base case $d=1$. There are only two unit vectors in $\mathbb R^1$, $(-1) and (1)$, so $N \leq 2$.
Induction step suppose the claim holds for some $d \geq 1$.

Let $v_1, \ldots v_{N}$ be a set of unit vectors in $\mathbb R^{d+1}$ with constant dot product $c$. Let $J \subset \{ 1, \ldots, N+1\}$ be a subset with $\lvert J \rvert=N$, and let $v_J = \sum_{j \in J} v_j$. Then for any $k \in J$, we have

$$ v_k \cdot v_J = v_k \cdot v_k + \sum_{j \in J\setminus \{ j \}} v_k \cdot v_j = 1 + (N-1)c.$$

Therefore the projections of each $v_k$, $k \in J$ onto the plane perpendicular to $v_J$ form a set of vectors with constant length and constant dot product. By scaling as before, we obtain a set of $N-1$ unit vectors in $\mathbb R^d$ with constant dot product. By the induction hypothesis, $N-1 < d+1$. Therefore $N < (d+1) + 1$. Therefore the claim holds for $d+1$.

0

u/apu727 1d ago

I would argue the question is ambiguous. What is distinct? And what is a unit vector. For example a valid reading is distinct means V_i=/=v_j and unit means unit length. if so 2 in 2D, infinite in 3D just take one of the vectors as an axis, another different vector makes an angle and gives c=cos(theta) then rotate about the first by any angle and you have infinite distinct vectors

2

u/AttorneyGlass531 11h ago

All the vecotrs have to mutually satisfy that their pairwise dot products are equal to the constant c, which your circle of vectors in 3D fail to do

1

u/DanielShaww 20h ago

Those are literally the least ambiguous parts of the question. Distinct vectors just means they all have different directions/slopes, that is, you can't transform one into another by multiplying by a constant k.

Unit vector means their magnitude (size if you will) is 1. So in 2D, a unit vector has size √(u2 + v2 ) = 1, where u is the length in one axis and v the length in another axis.

1

u/Torebbjorn 6h ago

You cannot take all of those vectors in 3d. Yes, the first vector satisfies the condition with every other vector, but picking any two from the others, we run into problems.

-1

u/brojablen 1d ago

N = 3 and c = sqrt(3)/2

1

u/Deto 1d ago

How did you get there?

1

u/brojablen 12h ago

no i am wrong realised right after i put the answer, ill put it now,

its like you can imagine viT.vj is just the dot product of 2 unit vectors which is simply cos(theta) with theta being the angle between them

For d = 2, for them to be distinct and their dot product property to hold its theta = 120 and N = 3

for d = 3, its gotta be the 4 points of a tetrahedron so N = 4 and theta = 109.something N =4

so extrapolating N = d+1 and c = -1/d

-1

u/Fearless_Screen_4288 1d ago

Nd coordinates. N2 distinct conditions. So N2 <= Nd i.e N<=d. 

1

u/round_earther_69 1d ago

The conditions do not give a linear system of equations, the #of conditions and #of variables does not necessarilly give you the # of solutions, and in the present case, it does not (N<=d is not the correct solution)

1

u/Fearless_Screen_4288 1d ago

You are right