For n=1000 the computation of your c coefficients is so inaccurate that it produces some humonguous values. Are you not getting a ton of warnings related to calling nchoosek
? You will need to compute them in some more clever way that does not lead to overflows.
That’s why for n=1000 Mosek says
Mosek error: MSK_RES_ERR_HUGE_AIJ (A numerically huge value is specified for an element in A.)
------------------------------------------------------------
Status: Error
Optimal value (cvx_optval): NaN
Reference to non-existent field 'sol'.
For n=10 it solves nicely.