Builds and solves a simple least-squares problem using cvx

echo on

n = 100;
A = randn(2*n,n);
b = randn(2*n,1);
cvx_begin
   variable x(n)
   minimize( norm( A*x-b ) )
cvx_end

echo off
 
Calling SDPT3: 201 variables, 101 equality constraints
   For improved efficiency, SDPT3 is solving the dual problem.
------------------------------------------------------------

 num. of constraints = 101
 dim. of socp   var  = 201,   num. of socp blk  =  1
*******************************************************************
   SDPT3: Infeasible path-following algorithms
*******************************************************************
 version  predcorr  gam  expon  scale_data
    NT      1      0.000   1        0    
it pstep dstep pinfeas dinfeas  gap      mean(obj)   cputime
-------------------------------------------------------------------
 0|0.000|0.000|6.6e+00|1.5e+00|2.5e+02| 0.000000e+00| 0:0:00| chol  1  1 
 1|0.953|1.000|3.1e-01|6.8e-03|2.3e+01|-1.537672e+01| 0:0:00| chol  1  1 
 2|1.000|1.000|7.4e-08|6.8e-04|1.6e+00|-9.722419e+00| 0:0:00| chol  1  1 
 3|0.986|0.986|1.8e-08|7.7e-05|2.3e-02|-9.733358e+00| 0:0:00| chol  1  1 
 4|0.989|0.989|5.8e-09|7.5e-06|2.5e-04|-9.733961e+00| 0:0:00| chol  1  1 
 5|0.989|0.989|6.3e-11|8.4e-08|2.8e-06|-9.734018e+00| 0:0:00| chol  1  1 
 6|0.989|0.989|8.0e-13|9.3e-10|3.1e-08|-9.734018e+00| 0:0:01|
  stop: max(relative gap, infeasibilities) < 1.49e-08
-------------------------------------------------------------------
 number of iterations   =  6
 primal objective value = -9.73401819e+00
 dual   objective value = -9.73401821e+00
 gap := trace(XZ)       = 3.10e-08
 relative gap           = 1.51e-09
 actual relative gap    = 8.42e-10
 rel. primal infeas     = 8.03e-13
 rel. dual   infeas     = 9.32e-10
 norm(X), norm(y), norm(Z) = 1.4e+00, 9.8e+00, 1.4e+01
 norm(A), norm(b), norm(C) = 1.4e+02, 2.0e+00, 1.5e+01
 Total CPU time (secs)  = 0.6  
 CPU time per iteration = 0.1  
 termination code       =  0
 DIMACS: 8.0e-13  0.0e+00  4.0e-09  0.0e+00  8.4e-10  1.5e-09
-------------------------------------------------------------------
------------------------------------------------------------
Status: Solved
Optimal value (cvx_optval): +9.73402