Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
? why cannot get LS soln with mini norm

Subject: ? why cannot get LS soln with mini norm

From: Cheng Cosine

Date: 14 Jun, 2010 08:19:42

Message: 1 of 2

Hi:

 I tried the following algorithm to see if I can get min norm LS soln
for


solving min f, f = 0.5*norm( A*x-b ), A is m-by-n and m < n. But the
algorithm


did not converge to the min norm LS soln. Does anyone know what's
wrong?


 The algorithm used is:


  x(k+1) = x(k)-pinv(A)*f(k)


 The algorithm was tested using the following Matlab scripts.


 Thanks,


A = [1, 2, 3, 4;
     4, 5, 6, 7;
     7, 8, 9, 10;
     8, 4, 9, 1];
x_true = [9; 1; 6; 2];
b = A*x_true;


% Setup the under-determined system
N = 2;
A_und = A(1:N,:); b_und = b(1:N);
x_minLS = pinv(A_und)*b_und;
J_und = A_und;


x_guess = rand(size(x_minLS));


IterMaxNo = 500; IterDelta = 1.0E-7;


% compatible case
[x_und_gnpinv, n_iter] = ...
    gnpinvL(x_guess, J_und, A_und, b_und, IterMaxNo, IterDelta);


function [y, n] = gnpinvL(x_old, J, A, b, IterMaxNo, IterDelta)


n = 0;


while ( n <= IterMaxNo )
    f = A*x_old-b;
    tmp = pinv(J)*f;
    x_new = x_old-tmp;
    n = n+1;


    DiffNorm = norm(f);


    if DiffNorm < IterDelta
      y = x_new;
      fprintf(' Converged! \n');
      return
    end % if converged


    x_old = x_new;
end % while


y = x_new;
fprintf(' Iteration Exceeded! \n');

Subject: ? why cannot get LS soln with mini norm

From: Torsten Hennig

Date: 14 Jun, 2010 08:50:22

Message: 2 of 2

> Hi:
>
> I tried the following algorithm to see if I can get
> t min norm LS soln
> for
>
>
> solving min f, f = 0.5*norm( A*x-b ), A is m-by-n and
> m < n. But the
> algorithm
>
>
> did not converge to the min norm LS soln. Does anyone
> know what's
> wrong?
>
>
> The algorithm used is:
>
>
> x(k+1) = x(k)-pinv(A)*f(k)
>
>
> The algorithm was tested using the following Matlab
> b scripts.
>
>
> Thanks,
>
>
> A = [1, 2, 3, 4;
> 4, 5, 6, 7;
> 7, 8, 9, 10;
> 8, 4, 9, 1];
> x_true = [9; 1; 6; 2];
> b = A*x_true;
>
>
> % Setup the under-determined system
> N = 2;
> A_und = A(1:N,:); b_und = b(1:N);
> x_minLS = pinv(A_und)*b_und;
> J_und = A_und;
>
>
> x_guess = rand(size(x_minLS));
>
>
> IterMaxNo = 500; IterDelta = 1.0E-7;
>
>
> % compatible case
> [x_und_gnpinv, n_iter] = ...
> gnpinvL(x_guess, J_und, A_und, b_und, IterMaxNo,
> xNo, IterDelta);
>
>
> function [y, n] = gnpinvL(x_old, J, A, b, IterMaxNo,
> IterDelta)
>
>
> n = 0;
>
>
> while ( n <= IterMaxNo )
> f = A*x_old-b;
> tmp = pinv(J)*f;
> x_new = x_old-tmp;
> n = n+1;
>
>
> DiffNorm = norm(f);
>
>
> if DiffNorm < IterDelta
> y = x_new;
> fprintf(' Converged! \n');
> return
> end % if converged
>
>
> x_old = x_new;
> end % while
>
>
> y = x_new;
> fprintf(' Iteration Exceeded! \n');
>
>

Why do you want to determine a least-squares solution
for an _underdetermined_ system ?
This approach is usually used for _overdetermined_
systems.
The affine solution of an underdetermined system is
given by
x_0 + kern(A)
where x_0 is a special solution of the system
A*x = b.

Best wishes
Torsten.

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us