From: David Brigada on
> Whith all respect, does a bug or glitch really exist?
> To decompose a complex number into its real and
> imaginary components (assuming RPN mode):
>
> 1. Input: 3+SQRT(-5)
> 2. On stack: 3+SQRT(-1)*SQRT(5)
> 3. EVAL
> 4. On stack: 3+i*SQRT(5)

This EVAL is what makes this example work. Without the EVAL, RE returns
3+SQRT(-1)*SQRT(5), and IM returns 0.

The functions work properly if flag -3 is set, but you get real, not
symbolic results then.

> 5. ENTER (to duplicate)
> 6. RE: 3 on stack
> 7. SWAP
> 8. IM: SQRT(5) on stack
>
> Rather exact!
>
> Regards
> Hans

From: TW on
> This EVAL is what makes this example work.  Without the EVAL, RE returns
> 3+SQRT(-1)*SQRT(5), and IM returns 0.

Looking at it, the problem seems to be in the xSYMIM command which is
as such.

COMPLEX? case inaddtIM
ISMETACOMPLEX? NOTcase NDROPZ0ONE ( -> 0 )
SETCOMPLEX
allrealflag TestSysFlag OBJ>R
allrealflag SetSysFlag ( meta )
inaddtIM ( im )
allrealflag R>OBJ ITE SetSysFlag ClrSysFlag ( im )
CLRCOMPLEX

The ISMETACOMPLEX? tests to see if there is either a complex object,
or an i variable. Finding none, it returns 0.

This works, except for the fact that the object hasn't been evaluated
yet so there is no i variable in there yet.

To work around this issue at the moment, your could make sure the
object is EVALed first, then run IM.

TW



From: hgabert on
On Feb 12, 8:44 am, TW <timwess...(a)gmail.com> wrote:
> > This EVAL is what makes this example work.  Without the EVAL, RE returns
> > 3+SQRT(-1)*SQRT(5), and IM returns 0.
>
> Looking at it, the problem seems to be in the xSYMIM command which is
> as such.
>
>   COMPLEX? case inaddtIM
>   ISMETACOMPLEX? NOTcase NDROPZ0ONE             ( -> 0 )
>   SETCOMPLEX
>   allrealflag TestSysFlag OBJ>R
>   allrealflag SetSysFlag                        ( meta )
>   inaddtIM                                      ( im )
>   allrealflag R>OBJ ITE SetSysFlag ClrSysFlag        ( im )
>   CLRCOMPLEX
>
> The ISMETACOMPLEX? tests to see if there is either a complex object,
> or an i variable. Finding none, it returns 0.
>
> This works, except for the fact that the object hasn't been evaluated
> yet so there is no i variable in there yet.
>
> To work around this issue at the moment, your could make sure the
> object is EVALed first, then run IM.
>
> TW

Yes, this behavior affects other functions as well.

ARG, ABS, CONJ, and SIGN all seem to be affected, in addition to RE
and IM.

For example, take the conjugate function,

-3
SQRT
CONJ

returns SQRT(-1)*SQRT(3)

->NUM (0, 1.73205080757)

But

-3
SQRT
EVAL
CONJ

returns -i*SQRT(3)

->NUM (0,-1.73205080757)

From: hgabert on
On Feb 12, 9:37 am, "hgab...(a)xmission.com" <hgab...(a)xmission.com>
wrote:
> On Feb 12, 8:44 am, TW <timwess...(a)gmail.com> wrote:
>
>
>
> > > This EVAL is what makes this example work.  Without the EVAL, RE returns
> > > 3+SQRT(-1)*SQRT(5), and IM returns 0.
>
> > Looking at it, the problem seems to be in the xSYMIM command which is
> > as such.
>
> >   COMPLEX? case inaddtIM
> >   ISMETACOMPLEX? NOTcase NDROPZ0ONE             ( -> 0 )
> >   SETCOMPLEX
> >   allrealflag TestSysFlag OBJ>R
> >   allrealflag SetSysFlag                        ( meta )
> >   inaddtIM                                      ( im )
> >   allrealflag R>OBJ ITE SetSysFlag ClrSysFlag        ( im )
> >   CLRCOMPLEX
>
> > The ISMETACOMPLEX? tests to see if there is either a complex object,
> > or an i variable. Finding none, it returns 0.
>
> > This works, except for the fact that the object hasn't been evaluated
> > yet so there is no i variable in there yet.
>
> > To work around this issue at the moment, your could make sure the
> > object is EVALed first, then run IM.
>
> > TW
>
> Yes, this behavior affects other functions as well.
>
> ARG, ABS, CONJ, and SIGN all seem to be affected, in addition to RE
> and IM.
>
> For example, take the conjugate function,
>
> -3
> SQRT
> CONJ
>
> returns SQRT(-1)*SQRT(3)
>
> ->NUM (0, 1.73205080757)
>
> But
>
> -3
> SQRT
> EVAL
> CONJ
>
> returns -i*SQRT(3)
>
> ->NUM (0,-1.73205080757)

Also, this is interesting:

Clear flag -128

'IM(SQRT(X))'
{ X -2 }
|
returns

(-RE(-2)+SQRT(RE(-2)^2+ . . . )'

EVAL

returns ?

and ->NUM returns "Undefined Result"

Compare this to the original post, where for this problem, flag -128
was set, and the wrong result 0 was returned.

But,

'IM(SQRT(X))'
'X=-2'
SUBST

works correctly and returns SQRT(2), with flag -128 either clear or
set!
From: Veli-Pekka.Nousiainen on
TW wrote:
>> This EVAL is what makes this example work. Without the EVAL, RE returns
>> 3+SQRT(-1)*SQRT(5), and IM returns 0.
>
> Looking at it, the problem seems to be in the xSYMIM command which is
> as such.
>
> COMPLEX? case inaddtIM
> ISMETACOMPLEX? NOTcase NDROPZ0ONE ( -> 0 )
> SETCOMPLEX
> allrealflag TestSysFlag OBJ>R
> allrealflag SetSysFlag ( meta )
> inaddtIM ( im )
> allrealflag R>OBJ ITE SetSysFlag ClrSysFlag ( im )
> CLRCOMPLEX
>
> The ISMETACOMPLEX? tests to see if there is either a complex object,
> or an i variable. Finding none, it returns 0.
>
> This works, except for the fact that the object hasn't been evaluated
> yet so there is no i variable in there yet.
>
> To work around this issue at the moment, your could make sure the
> object is EVALed first, then run IM.
>
> TW
>
>
>
Is this still present in 2.15?
Oh well..just another bug fix...
BTW Tim,
Did you use Nosy?