Polynomial roots

classic Classic list List threaded Threaded
3 messages Options
Inderpreet Arora-2 Inderpreet Arora-2
Reply | Threaded
Open this post in threaded view
|

Polynomial roots

Hello,
I want to compare roots of a polynomial with a number. But it gives error. Consider a simple e.g.,

a = [2 3];
s = %s;
x = s^2 - 5*s + 6;
r = roots(x); r1 = [roots(x)]';
t1 = type(a);
t2 = type(r);
a > 2
r > 2

It does the comparison for a (done for verification) but gives the following error for r and r1, though their types are same,

Undefined operation for the given operands
check or define function %s_2_s for overloading

I tried in versions 4.1 and 4.1.2. Please guide. Thanks.

Sincerely,
Inderpreet





Francois Vogel-2 Francois Vogel-2
Reply | Threaded
Open this post in threaded view
|

Re: Polynomial roots

-->real(r) > 2
  ans  =

   F
   T

Francois


Inderpreet Arora said on 10/01/2009 18:33:

> Hello,
> I want to compare roots of a polynomial with a number. But it gives
> error. Consider a simple e.g.,
>
> a = [2 3];
> s = %s;
> x = s^2 - 5*s + 6;
> r = roots(x); r1 = [roots(x)]';
> t1 = type(a);
> t2 = type(r);
> a > 2
> r > 2
>
> It does the comparison for a (done for verification) but gives the
> following error for r and r1, though their types are same,
>
> Undefined operation for the given operands
> check or define function %s_2_s for overloading
>
> I tried in versions 4.1 and 4.1.2. Please guide. Thanks.
>
> Sincerely,
> Inderpreet

Inderpreet Arora-2 Inderpreet Arora-2
Reply | Threaded
Open this post in threaded view
|

Re: Polynomial roots

Thanks. Now, I could figure out that it is stored with an (eventually zero) imaginary part (Help: Description of isreal function).

-->isreal(r)
 ans  =

  F 

-->isreal(a)
 ans  =

  T

Sincerely,
Inderpreet


--- On Sat, 1/10/09, Fran├žois Vogel <[hidden email]> wrote:
From: Fran├žois Vogel <[hidden email]>
Subject: Re: [scilab-Users] Polynomial roots
To: [hidden email]
Date: Saturday, January 10, 2009, 6:05 PM

-->real(r) > 2
ans =

F
T

Francois


Inderpreet Arora said on 10/01/2009 18:33:
> Hello,
> I want to compare roots of a polynomial with a number. But it gives error.
Consider a simple e.g.,

>
> a = [2 3];
> s = %s;
> x = s^2 - 5*s + 6;
> r = roots(x); r1 = [roots(x)]';
> t1 = type(a);
> t2 = type(r);
> a > 2
> r > 2
>
> It does the comparison for a (done for verification) but gives the
following error for r and r1, though their types are same,
>
> Undefined operation for the given operands
> check or define function %s_2_s for overloading
>
> I tried in versions 4.1 and 4.1.2. Please guide. Thanks.
>
> Sincerely,
> Inderpreet