Equality constrained norm minimization.

% This script constructs a random equality-constrained norm minimization
% problem and solves it using CVX. You can also change p to +2 or +Inf
% to produce different results. Alternatively, you an replace
%     norm( A * x - b, p )
% with
%     norm_largest( A * x - b, 'largest', p )
% for 1 <= p <= 2 * n.

% Generate data
p = 1;
n = 10; m = 2*n; q=0.5*n;
A = randn(m,n);
b = randn(m,1);
C = randn(q,n);
d = randn(q,1);

% Create and solve problem
cvx_begin
   variable x(n)
   dual variable y
   minimize( norm( A * x - b, p ) )
   subject to
        y : C * x == d;
cvx_end

% Display results
disp( sprintf( 'norm(A*x-b,%g):', p ) );
disp( [ '   ans   =   ', sprintf( '%7.4f', norm(A*x-b,p) ) ] );
disp( 'Optimal vector:' );
disp( [ '   x     = [ ', sprintf( '%7.4f ', x ), ']' ] );
disp( 'Residual vector:' );
disp( [ '   A*x-b = [ ', sprintf( '%7.4f ', A*x-b ), ']' ] );
disp( 'Equality constraints:' );
disp( [ '   C*x   = [ ', sprintf( '%7.4f ', C*x ), ']' ] );
disp( [ '   d     = [ ', sprintf( '%7.4f ', d   ), ']' ] );
 
Calling SeDuMi: 50 variables (10 free), 25 equality constraints
------------------------------------------------------------------------
SeDuMi 1.1 by AdvOL, 2005 and Jos F. Sturm, 1998, 2001-2003.
Alg = 2: xz-corrector, Adaptive Step-Differentiation, theta = 0.250, beta = 0.500
Split 10 free variables
eqs m = 25, order n = 61, dim = 61, blocks = 1
nnz(A) = 540 + 0, nnz(ADA) = 625, nnz(L) = 325
 it :     b*y       gap    delta  rate   t/tP*  t/tD*   feas cg cg  prec
  0 :            5.04E+001 0.000
  1 :  1.25E+001 1.21E+001 0.000 0.2398 0.9000 0.9000   2.40  1  1  9.7E-001
  2 :  1.81E+001 2.67E+000 0.000 0.2208 0.9000 0.9000   1.09  1  1  2.5E-001
  3 :  1.93E+001 6.94E-001 0.000 0.2598 0.9000 0.9000   1.01  1  1  6.7E-002
  4 :  1.95E+001 1.70E-001 0.000 0.2452 0.9000 0.9000   1.00  1  1  1.7E-002
  5 :  1.96E+001 6.75E-003 0.000 0.0397 0.9900 0.9900   1.00  1  1  
iter seconds digits       c*x               b*y
  5      0.1  15.7  1.9637293286e+001  1.9637293286e+001
|Ax-b| =  5.6e-015, [Ay-c]_+ =  2.8E-015, |x|= 1.1e+001, |y|= 6.7e+000

Detailed timing (sec)
   Pre          IPM          Post
1.001E-002    5.007E-002    4.006E-002    
Max-norms: ||b||=2.325211e+000, ||c|| = 1,
Cholesky |add|=0, |skip| = 0, ||L.L|| = 2.6152.
------------------------------------------------------------------------
Status: Solved
Optimal value (cvx_optval): +19.6373
norm(A*x-b,1):
   ans   =   19.6373
Optimal vector:
   x     = [  0.0454  0.7771 -0.4288 -0.2071 -0.6081  0.0065 -0.0013  0.0645 -0.3340 -0.6522 ]
Residual vector:
   A*x-b = [ -0.0000 -1.0527 -0.7833  1.6843  0.1257  2.5993  1.2661  0.0000  0.2758 -1.6365 -0.9791  2.6851  0.8774 -0.8686  0.0000  1.6512 -0.0000  1.5824 -0.0000  1.5699 ]
Equality constraints:
   C*x   = [ -1.0290  0.2431 -1.2566 -0.3472 -0.9414 ]
   d     = [ -1.0290  0.2431 -1.2566 -0.3472 -0.9414 ]