[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: rem
From: |
Ted Harding |
Subject: |
RE: rem |
Date: |
Sat, 22 Nov 1997 01:34:52 -0000 (GMT) |
On 21-Nov-97 John W. Eaton wrote:
> On 19-Nov-1997, Charles E. Suprin <address@hidden> wrote:
>| This is a simple question. rem in octave claims to not do imaginary
>| numbers. It commnets that the matlab one is a bunch of hooey.
>| However the complex nature is used in the unwrap function. Has anyone
>| implemented a matlab compatible rem function.
>
> What is rem supposed to do for complex numbers? Can someone point me
> to a textbook definition?
I don't know of one. I doubt there's a meaningful one that treats real and
complex parts on the same footing and is closely analgous to the case for
reals. If anyone knows better it would be interesting to hear of it.
For example, if you use the "fix" definition (rounding each of real &
imaginary towards 0), then
A: (2 + 3*i) = (2 + 0*i)*(1 + 1*i) + (0 + 1*i)
so rem(2 + 3*i, 1 + 1*i) = (0 + 1*i)
But you can also write
B: (2 + 3*i) = (2 + 1*i)*(1 + 1*i) + (1 + 0*i)
and (independently of "fix" considerations) why prefer (A) to (B)?
There are various ways to approach the concept of remainder for reals. One
is
y = m*k + r [ r == rem(y.k) ] where m = integer_part(y/k)
where 0 <= |r| < |k| and r has the same sign as y. This is the same as the
"fix" definition, for reals.
Another is
y = m*k + r [ r == rem(y,k) ] where m = floor(y/k)
and in this case 0 <= r < |k|.
If you think of generalising these to the complex numbers, then the fact
that the complex numbers are not ordered removes the determinism of the
reals.
For instance, in the above example, if you choose to carry over the
definition of m then both "fix" and "floor" give case (A). Again, a
condition 0 <= |r| < |k| gives you either (A) or (B). Further, a condition
that m is the number (with integer real & imag parts) of largest complex
modulus such that y = m*k + r with the condition 0 <= |r| < |k| gives case
(B) rather than (A). You cannot have anything like "r has the same sign as
k" for complex numbers.
So I guess what definition you choose for "rem" in the complex case depends
on what properties you want it to have, and there's nothing that strikes me
as so uniquely desirable that it fixes an obvious choice for the definition.
Maybe if you can think of a genuine use for "rem" in the complex case then
you already have a reason (whatever it is) for choosing a particular
definition. But is this unique?
What do others think?
Ted.
--------------------------------------------------------------------
E-Mail: Ted Harding <address@hidden>
Date: 22-Nov-97 Time: 01:34:52
--------------------------------------------------------------------
- rem, Charles E. Suprin, 1997/11/19
- rem, John W. Eaton, 1997/11/21
- RE: rem,
Ted Harding <=
- Re: rem, Raymond E. Rogers, 1997/11/22