∇ProvenDecisions
Ctrl K

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.

Answer. The Frobenius distance is 0.438256. X = [[1, 0.694215, 0.525864], [0.694215, 1, -0.24715], [0.525864, -0.24715, 1]]; distance = 0.438256; min_eigenvalue = 0.

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

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.

distance0.438256min_eigenvalue0

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,1

Change the numbers and solve it

Checked: 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

All 50 solved examples

Try ProvenDecisions free: type, photograph or say an optimization problem; every answer is checked by a solver.

What do you want to optimize?

Type the math, describe it in words, snap a photo or say it. ProvenDecisions builds the model, solves it, checks it and walks you through it.

One constraint per line, or separated by commas. Add integer: x, y or binary: z for whole-number decisions. LaTeX works too.

Try: