KatInterview

Smallest Equicorrelation Value for a Valid 3x3 Matrix

Math & Bit ManipulationAuto-graded · 16 test cases
EasyAuto-gradedMath & Bit Manipulationlinear-algebraeigenvaluespositive-semidefinite

Last updated

Determine the least real parameter for which a 3x3 symmetric matrix with unit diagonal and equal off-diagonal entries is positive semidefinite, using eigenvalue or minor analysis.

Consider the family of symmetric 3x3 matrices M(t) whose diagonal entries are all 1 and whose six off-diagonal entries are all equal to a real number t:

M(t) = [[1, t, t],
        [t, 1, t],
        [t, t, 1]]

A symmetric matrix is positive semidefinite (PSD) if xᵀ M x >= 0 for every real vector x. Equivalently, all of its eigenvalues are nonnegative.

Write a function that returns the smallest real value of t for which M(t) is positive semidefinite.

The function takes no arguments and returns a single float.

Constraints

  • t is a real number; the answer is the exact minimum of the set of t for which M(t) is PSD.
  • The matrix is always 3x3 with diagonal entries equal to 1.
  • The function takes no input and must return a float.
  • The endpoint itself counts: semidefinite allows an eigenvalue equal to zero, so the minimum is attained.

Examples

Example 1

Input: smallest_equicorrelation()

Output: -0.5

Hints

Hint 1

Write M(t) as (1 - t) times the identity plus t times the all-ones matrix J. Eigenvectors of M(t) are then the eigenvectors of J.

Hint 2

The all-ones matrix J has eigenvalue 3 for the vector (1, 1, 1) and eigenvalue 0 on the plane orthogonal to it. Shift these by (1 - t) after scaling by t.

Hint 3

M(t) has eigenvalues 1 + 2t (once) and 1 - t (twice). Require both to be nonnegative and take the lower end of the resulting interval.