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
n = 100;
A = randn(2*n,n);
b = randn(2*n,1);
cvx_begin
   variable x(n)
   minimize( norm( A*x-b ) )
cvx_end
 
Calling sedumi: 201 variables, 101 equality constraints
   For improved efficiency, sedumi is solving the dual problem.
------------------------------------------------------------
SeDuMi 1.21 by AdvOL, 2005-2008 and Jos F. Sturm, 1998-2003.
Alg = 2: xz-corrector, Adaptive Step-Differentiation, theta = 0.250, beta = 0.500
eqs m = 101, order n = 3, dim = 202, blocks = 2
nnz(A) = 20001 + 0, nnz(ADA) = 10201, nnz(L) = 5151
 it :     b*y       gap    delta  rate   t/tP*  t/tD*   feas cg cg  prec
  0 :            6.78E+00 0.000
  1 :  -7.73E+00 1.60E+00 0.000 0.2367 0.9000 0.9000  -0.46  1  1  2.0E+00
  2 :  -9.75E+00 1.42E-01 0.000 0.0886 0.9900 0.9900   0.99  1  1  2.0E-01
  3 :  -9.54E+00 5.70E-05 0.219 0.0004 0.9999 0.9999   1.03  1  1  8.3E-05
  4 :  -9.54E+00 2.62E-07 0.000 0.0046 0.9990 0.9990   1.28  1  1  2.9E-07
  5 :  -9.54E+00 3.59E-14 0.000 0.0000 1.0000 1.0000   1.00  1  1  4.1E-14

iter seconds digits       c*x               b*y
  5      0.0   Inf -9.5449220247e+00 -9.5449220247e+00
|Ax-b| =   2.5e-14, [Ay-c]_+ =   6.5E-14, |x|=  1.4e+00, |y|=  9.6e+00

Detailed timing (sec)
   Pre          IPM          Post
1.000E-02    4.000E-02    1.000E-02    
Max-norms: ||b||=1, ||c|| = 3.229561e+00,
Cholesky |add|=0, |skip| = 0, ||L.L|| = 1.
------------------------------------------------------------
Status: Solved
Optimal value (cvx_optval): +9.54492

echo off