Nearest correlation matrix: a semidefinite programming example, solved and checked
The nearest correlation matrix is a classic semidefinite programming problem. Here it is solved by a real solver (CLARABEL) and checked: every constraint, and the optimality certificate. Change the numbers below and solve your own.
Solve your own version free, no account needed
The problem
The estimated correlation matrix [[1, 0.9, 0.7], [0.9, 1, -0.4], [0.7, -0.4, 1]] is not positive semidefinite. Find the nearest valid correlation matrix in Frobenius norm.
How the model was built
- ‖X − A‖F, the Frobenius distance, is the square root of the sum of the squared differences between the entries of X and A.
- X ⪰ 0 (positive semidefinite) means no eigenvalue is below 0, which every real correlation matrix satisfies. Xii = 1: each variable's correlation with itself is 1.
The model
Recognized as a standard problem: nearest correlation matrix. The formula states the optimization being solved.
Problem type
Complexity level 4: convex: a semidefinite program (the PSD cone is convex; no determinant constraint is needed). Method: CLARABEL.
The answer at a glance
The optimal value of each decision, as the solver returned it.
Verification
Convex SDP: the KKT conditions (PSD multiplier S with S X = 0) certify the global optimum (checked to 1e-4, the interior-point accuracy). Verified.
Solve your own
This is the model as the app reads it. Change any number and solve it in the free box on the front page (no account needed).
pattern: nearest_correlation matrix=1,0.9,0.7;0.9,1,-0.4;0.7,-0.4,1Checked: the app's answer matches the reference answer in our test set, which two solvers (CLARABEL, SCS) agree on. Built 2026-11-10.
Related examples
Try ProvenDecisions free: type, photograph or say an optimization problem; every answer is checked by a solver.