(no subject)



t t <lan1967 at mail.ru> writes:
> Hello, people!
> Sorry for disturbance.
> I got a question.
> I need to use one of the found roots for calculation.
> But when I use one of them g[2] to compare the program doesn't really
> do any comparison.
> How to use the root for comparison?
> Thank you for your attention.
>
> w:realroots(g^2-1);
> w[1];
> if (w[2]<2) then j:0;
> j;?
>
> [g=-1,g=1]
> g=-1
> (%o330) if g=-1<2 then j:0 
> (%o331) j?

Hi,

There are two things that seem to be confusing you. Firstly, the second
element of w is the equation g=1:

(%i14) w:realroots(g^2-1);
(%o14)                         [g = - 1, g = 1]
(%i15) w[2];
(%o15)                               g = 1

To get the "1" bit, use the rhs() function:

(%i16) rhs(w[2]);
(%o16)                                 1

Now you want to check how big it is. Just testing "rhs(w[2]) < 2;"
doesn't work:

(%i18) rhs(w[2]) < 2;
(%o18)                               1 < 2

because Maxima doesn't perform (in)equality tests like this unless you
tell it to. However, the is() function does what you need:

(%i19) is(rhs(w[2]) < 2);
(%o19)                               true

So I think you want something like:

(%i21) if (is(rhs(w[2]) < 2)) then j:0$

(%i22) j;
(%o22)                                 0


Rupert
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 315 bytes
Desc: not available
URL: <http://www.math.utexas.edu/pipermail/maxima/attachments/20110520/627733fe/attachment.pgp>;