From: James Tursa on
"Laurentiu " <laurREMOVECAPSmarinovici(a)gmail.com> wrote in message <hrvb7u$stb$1(a)fred.mathworks.com>...
>
> The real thing that I do is computing some coefficients in a loop using another MATLAB function, and the small values appear randomly, so basically, I cannot quite know their values so that I could test them. Besides I would like to continue my computations with them being null automatically.

Why do you care? Why does it make a difference to you if a small number is used in the computation of a polynomial vs a 0 used in the computation?

James Tursa
From: Laurentiu on
"James Tursa" <aclassyguy_with_a_k_not_a_c(a)hotmail.com> wrote in message <hrvbql$9d3$1(a)fred.mathworks.com>...
> "Laurentiu " <laurREMOVECAPSmarinovici(a)gmail.com> wrote in message <hrvb7u$stb$1(a)fred.mathworks.com>...
> >
> > The real thing that I do is computing some coefficients in a loop using another MATLAB function, and the small values appear randomly, so basically, I cannot quite know their values so that I could test them. Besides I would like to continue my computations with them being null automatically.
>
> Why do you care? Why does it make a difference to you if a small number is used in the computation of a polynomial vs a 0 used in the computation?
>
> James Tursa

Because I am computing some controllers, and test their performances, and sometimes not being able to cancel out poles and zeros that are very very small, but not exactly equal, keeps bringing me in the impossibility to use the transfer functions further.
From: Walter Roberson on
Laurentiu wrote:

> Does anybody have any suggestions about how I could let MATLAB know that
> it should consider a number like 5.67*10^(-5) equal to 0, especially
> since, for example, all the other coefficients of the polynomial are of
> at least 10^(-2) order?

I'm not entirely sure what you are asking. Are you asking that each time
that Matlab finds an intermediate result is less than a particular
magnitude, that it should underflow the intermediate result to zero?

If you are asking that, then please be aware that some CPUs have a
floating point reciprocal instruction, 1/X, and use it to transform a
vectorized division Y/X into a vectorized multiplication, Y * (1/X) as
multiplication is faster in hardware than division is. If your code had
divisions, then it might generate small intermediate results on your
behalf that you were thinking of as being relatively large quantities .

For example, you say that the other coefficients of the polynomial are
of at least 10^(-2) magnitude. That implies they might perhaps be of
10^5 magnitude. When you go to find the root of such a polynomial, at
some point you would end up dividing by that 10^5... and would be rather
surprised to have it underflow to 0 and then generate NaNs when you went
to divide by it....

There are a number of different algorithms where _differences_ between
values can become critical. The original magnitude can be large, but the
differences might be small, and it can be quite important to the
algorithm finding a correct solution that the differences are not zeroed
out.
From: Laurentiu on
Walter Roberson <roberson(a)hushmail.com> wrote in message <WCGEn.9$0M5.6(a)newsfe07.iad>...
> Laurentiu wrote:
>
> > Does anybody have any suggestions about how I could let MATLAB know that
> > it should consider a number like 5.67*10^(-5) equal to 0, especially
> > since, for example, all the other coefficients of the polynomial are of
> > at least 10^(-2) order?
>
> I'm not entirely sure what you are asking. Are you asking that each time
> that Matlab finds an intermediate result is less than a particular
> magnitude, that it should underflow the intermediate result to zero?
>
> If you are asking that, then please be aware that some CPUs have a
> floating point reciprocal instruction, 1/X, and use it to transform a
> vectorized division Y/X into a vectorized multiplication, Y * (1/X) as
> multiplication is faster in hardware than division is. If your code had
> divisions, then it might generate small intermediate results on your
> behalf that you were thinking of as being relatively large quantities .
>
> For example, you say that the other coefficients of the polynomial are
> of at least 10^(-2) magnitude. That implies they might perhaps be of
> 10^5 magnitude. When you go to find the root of such a polynomial, at
> some point you would end up dividing by that 10^5... and would be rather
> surprised to have it underflow to 0 and then generate NaNs when you went
> to divide by it....
>
> There are a number of different algorithms where _differences_ between
> values can become critical. The original magnitude can be large, but the
> differences might be small, and it can be quite important to the
> algorithm finding a correct solution that the differences are not zeroed
> out.

I understand what you are saying. For instance, one thing I get is like this 0.02202 z^4 + 0.04014 z^3 + 0.01426 z^2 - 0.003851 z + 6.895e-010, whose roots are -1.5098, -0.31309, -6.6241e-008. So instead of the 10^(-8) root, I would rather have it 0. Since it is fro a control application, I'd rather thing of it as right at the origin, than something really close to the origin.
From: dpb on
Laurentiu wrote:
....
> In my case, the smallest coefficients turn out to be the ones for x^0,
> so instead of having a zero root, I get some very small number. one
> example : 0.02202 z^4 + 0.04014 z^3 + 0.01426 z^2 - 0.003851 z + 6.895e-010

In that case, why not set up for the GLM and not estimate an intercept
instead?

--