Thread Subject: non-linear system ni=a*x+ni0 ( read below )

Subject: non-linear system ni=a*x+ni0 ( read below )

From: Carlo Castellucci

Date: 27 Feb, 2009 18:28:02

Message: 1 of 4

a=[-1,-1,0,1; 0,1,0,0; 1,-1,0,-1; 1,0,-1,0; -3,1,2,1.4; 0,0,1,0; 0,0,0,-0.1];
SBR=0.5; % actually SBR could be chosen in (0,1)
q=2.1587*SBR;
qtot=q+1.505/11;
ni0=[1;0;qtot;0;12.5/11;5/11;0];
ni=[17.7;4.37;4.47;4.44;18.13;7.7;0.36];
ni_ni0=ni-ni0;
[U S V]=svd(a);
x=V*pinv(S)*U'*ni_ni0;
disp(x);

The problem is that the x I get doesn't satisfy the relation in the title of this post...not even if I choose this other way : [Q R]=qr(a)... a=Q*R ...

Can it depend on the fact the matrix a is badly scaled ( cond(a,2) is near to 10 if I well remmeber... so certainly not low ) .

How can I get the right solution if ever there is one ? It's like a system made up of 7 equations and only 4 variables...so it might have no solution...am I right?

Please help me soon... my email is il.giocatore@yahoo.it

Thanks

Subject: non-linear system ni=a*x+ni0 ( read below )

From: John D'Errico

Date: 27 Feb, 2009 18:47:01

Message: 2 of 4

"Carlo Castellucci" <xxcarlo_rossixx@yahoo.it> wrote in message <go9bbi$auc$1@fred.mathworks.com>...
> a=[-1,-1,0,1; 0,1,0,0; 1,-1,0,-1; 1,0,-1,0; -3,1,2,1.4; 0,0,1,0; 0,0,0,-0.1];
> SBR=0.5; % actually SBR could be chosen in (0,1)
> q=2.1587*SBR;
> qtot=q+1.505/11;
> ni0=[1;0;qtot;0;12.5/11;5/11;0];
> ni=[17.7;4.37;4.47;4.44;18.13;7.7;0.36];
> ni_ni0=ni-ni0;
> [U S V]=svd(a);
> x=V*pinv(S)*U'*ni_ni0;
> disp(x);
>
> The problem is that the x I get doesn't satisfy the relation in the title of this post...not even if I choose this other way : [Q R]=qr(a)... a=Q*R ...
>
> Can it depend on the fact the matrix a is badly scaled ( cond(a,2) is near to 10 if I well remmeber... so certainly not low ) .
>
> How can I get the right solution if ever there is one ? It's like a system made up of 7 equations and only 4 variables...so it might have no solution...am I right?
>
> Please help me soon... my email is il.giocatore@yahoo.it

So many things to say. cond(a) approximately 10
is NOT even remotely badly scaled. In fact, this is
quite good. Where did you ever get the idea that
that is a big number? 1E10 is getting big, but there
is an exponential relationship between 10 and 1E10.

Why do you say this is a nonlinear system? It
appears quite linear to me.

Why do you expect that an overdetermined linear
system (one with more rows than columns) will
have an exact solution?

Finally, why are you using pinv in that way?
Do this:

x = pinv(a)*ni_ni0;

Or this

x = a\ni_ni0;

John

Subject: non-linear system ni=a*x+ni0 ( read below )

From: Carlo Castellucci

Date: 28 Feb, 2009 02:30:22

Message: 3 of 4

"John D'Errico" <woodchips@rochester.rr.com> wrote in message <go9cf5$qip$1@fred.mathworks.com>...
> "Carlo Castellucci" <xxcarlo_rossixx@yahoo.it> wrote in message <go9bbi$auc$1@fred.mathworks.com>...
> > a=[-1,-1,0,1; 0,1,0,0; 1,-1,0,-1; 1,0,-1,0; -3,1,2,1.4; 0,0,1,0; 0,0,0,-0.1];
> > SBR=0.5; % actually SBR could be chosen in (0,1)
> > q=2.1587*SBR;
> > qtot=q+1.505/11;
> > ni0=[1;0;qtot;0;12.5/11;5/11;0];
> > ni=[17.7;4.37;4.47;4.44;18.13;7.7;0.36];
> > ni_ni0=ni-ni0;
> > [U S V]=svd(a);
> > x=V*pinv(S)*U'*ni_ni0;
> > disp(x);
> >
> > The problem is that the x I get doesn't satisfy the relation in the title of this post...not even if I choose this other way : [Q R]=qr(a)... a=Q*R ...
> >
> > Can it depend on the fact the matrix a is badly scaled ( cond(a,2) is near to 10 if I well remmeber... so certainly not low ) .
> >
> > How can I get the right solution if ever there is one ? It's like a system made up of 7 equations and only 4 variables...so it might have no solution...am I right?
> >
> > Please help me soon... my email is il.giocatore@yahoo.it
>
> So many things to say. cond(a) approximately 10
> is NOT even remotely badly scaled. In fact, this is
> quite good. Where did you ever get the idea that
> that is a big number? 1E10 is getting big, but there 1E10=1
> is an exponential relationship between 10 and 1E10.
>
> Why do you say this is a nonlinear system? It
> appears quite linear to me.
>
> Why do you expect that an overdetermined linear
> system (one with more rows than columns) will
> have an exact solution?
>
> Finally, why are you using pinv in that way?
> Do this:
>
> x = pinv(a)*ni_ni0;
>
> Or this
>
> x = a\ni_ni0;
>
> John

1E10=1...maybe you meant 10E10 that is 10 billions...using pinv(A) or doing what I did is just the same...you can check the x you get will not satisfy at all the relation in the title of my post ( ni=a*x+ni0)...
The use of backslash ( x=a\ni_ni0) to solve the system is surely uncorrect as backslash is based on Gauss and is good for square systems only as I know ( when it comes to non-square matrix you just go for pinv ).
I really don't expect anything from a non-linear system ( and it is non-linear...linear means that every equation is a linear combination of variables...and this is not the case...so let's not make confusion )...I really don't know what to expect except a physically acceptable solution should come out of it...and to be so it should have each component belonging to the set of positive real numbers ( and not complex ones...as it happens )...thanks the same even if you made a little bit of confusion...and I am still in the middle of my issue...lol

Subject: non-linear system ni=a*x+ni0 ( read below )

From: John D'Errico

Date: 28 Feb, 2009 03:35:03

Message: 4 of 4

"Carlo Castellucci" <xxcarlo_rossixx@yahoo.it> wrote in message <goa7ju$jr6$1@fred.mathworks.com>...
> "John D'Errico" <woodchips@rochester.rr.com> wrote in message <go9cf5$qip$1@fred.mathworks.com>...
> > "Carlo Castellucci" <xxcarlo_rossixx@yahoo.it> wrote in message <go9bbi$auc$1@fred.mathworks.com>...
> > > a=[-1,-1,0,1; 0,1,0,0; 1,-1,0,-1; 1,0,-1,0; -3,1,2,1.4; 0,0,1,0; 0,0,0,-0.1];
> > > SBR=0.5; % actually SBR could be chosen in (0,1)
> > > q=2.1587*SBR;
> > > qtot=q+1.505/11;
> > > ni0=[1;0;qtot;0;12.5/11;5/11;0];
> > > ni=[17.7;4.37;4.47;4.44;18.13;7.7;0.36];
> > > ni_ni0=ni-ni0;
> > > [U S V]=svd(a);
> > > x=V*pinv(S)*U'*ni_ni0;
> > > disp(x);
> > >
> > > The problem is that the x I get doesn't satisfy the relation in the title of this post...not even if I choose this other way : [Q R]=qr(a)... a=Q*R ...
> > >
> > > Can it depend on the fact the matrix a is badly scaled ( cond(a,2) is near to 10 if I well remmeber... so certainly not low ) .
> > >
> > > How can I get the right solution if ever there is one ? It's like a system made up of 7 equations and only 4 variables...so it might have no solution...am I right?
> > >
> > > Please help me soon... my email is il.giocatore@yahoo.it
> >
> > So many things to say. cond(a) approximately 10
> > is NOT even remotely badly scaled. In fact, this is
> > quite good. Where did you ever get the idea that
> > that is a big number? 1E10 is getting big, but there 1E10=1
> > is an exponential relationship between 10 and 1E10.
> >
> > Why do you say this is a nonlinear system? It
> > appears quite linear to me.
> >
> > Why do you expect that an overdetermined linear
> > system (one with more rows than columns) will
> > have an exact solution?
> >
> > Finally, why are you using pinv in that way?
> > Do this:
> >
> > x = pinv(a)*ni_ni0;
> >
> > Or this
> >
> > x = a\ni_ni0;
> >
> > John
>
> 1E10=1...maybe you meant 10E10 that is 10 billions...

Wrong. I think you misunderstand what a
condition number is.

a=[-1,-1,0,1; 0,1,0,0; 1,-1,0,-1; 1,0,-1,0; -3,1,2,1.4; 0,0,1,0; 0,0,0,-0.1];
cond(a)
ans =
       9.6043

The condition number of this matrix is 10. It is
NOT 1E10.

This matrix is quite well conditioned. Read here
about what the condition number of a matrix
means and how to compute it.

http://en.wikipedia.org/wiki/Condition_number

It is the ratio of the largest to the smallest singular
value. What are the singular values of a?

svd(a)
ans =
       4.5206
       1.7682
       1.4784
      0.47069

Yes, the ratio is roughly 10, and as I said, this means
your matrix is quite well conditioned.


> using pinv(A) or doing what I did is just the same...

Sigh. It is pure silliness to apply pinv to a diagonal
matrix, known to be diagonal as the output from
svd. Especially so when pinv does it for you. Look
at the difference on a larger matrix so that we can
see a timing difference.

A = rand(200,100);

tic,[U,S,V] = svd(A);P = V*pinv(S)*U';toc
Elapsed time is 0.224069 seconds.

tic,P = pinv(A);toc
Elapsed time is 0.176897 seconds.

See that there is indeed a difference. The secondary
call to pinv has done much extra work. Of course,
in your problem, the small matrix is small enough
that the difference is inconsequential.
 
What you don't seem to understand is that when
you compute the svd of S, it still computes a singular
value decomposition. It still generates a pair of
orthogonal matrices, and it does additional matrix
multiplications. So the operation as you have done
is simply silly, computing TWO svds when only one
was necessary. That is what pinv does after all, just
a wrapper around a call to svd, with a little extra
work.


> you can check the x you get will not satisfy at all the relation in the title of my post ( ni=a*x+ni0)...
> The use of backslash ( x=a\ni_ni0) to solve the system is surely uncorrect as backslash is based on Gauss and is good for square systems only as I know ( when it comes to non-square matrix you just go for pinv ).

Again, you apparently don't understand how
how backslash works. It is indeed valid to apply
backslash to non-square systems.

You have apparently been given misinformation.


> I really don't expect anything from a non-linear system ( and it is non-linear...linear means that every equation is a linear combination of variables...and this is not the case...

Sigh. Again, you don't seem to really appreciate
what you are doing. Once you fix the value of qtot
and substitute it in, the system is indeed purely
linear. Were it not linear, the pinv operation you
tried would not work at all.



> so let's not make confusion )...I really don't know what to expect except a physically acceptable solution should come out of it...and to be so it should have each component belonging to the set of positive real numbers

Exactly where did you specify in your original
statement that the result must have all positive
elements? Please show me where that was
stated. I''ve quoted your original post, so feel
free.

If you wish to see a solution with all positive
elements, lsqnonneg will do it for you. This is
what it is designed for.

SBR=0.5; % actually SBR could be chosen in (0,1)
q=2.1587*SBR;
qtot=q+1.505/11;
ni0=[1;0;qtot;0;12.5/11;5/11;0];
ni=[17.7;4.37;4.47;4.44;18.13;7.7;0.36];
ni_ni0=ni-ni0;
[U S V]=svd(a);
x=V*pinv(S)*U'*ni_ni0

x =
       7.2638
      -4.0766
       8.3888
       16.236

Instead, if you are looking for a non-negative
solution, use the correct tool for non-negative
linear least squares:

xpos = lsqnonneg(a,ni_ni0)
xpos =
       8.2967
            0
       8.0374
       16.659

John

Tags for this Thread

Add a New Tag:

Separated by commas
Ex.: root locus, bode

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.

rssFeed for this Thread

Contact us at files@mathworks.com