Gerhard Niklasch on Sun, 1 Jul 2001 11:31:57 +0200 (MEST)

[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: modulus a+b*I

In response to:
> Message-ID: <>
> Date: Sun, 1 Jul 2001 01:06:27 -0700 (PDT)
> From: "Perry S. Glenn" <>
> I would expect to get the result
> z=a+b*I
> abs(z)= a^2+b^2

I hope not!  First, that would be the square of abs(z).  Second,
even that only when it is known in advance that a and b stand
for real numbers -- which gp has no reason to assume.

> ? z=a+I*b
> %1 = a + I*b
> ? abs(z)
> %2 = a + I*b

As with many other functions, this got applied to each
coefficient of the multivariate polynomial.  (The only
surprise here is that it left I alone, whereas abs(I)
returns 1.000000000000000000000000000 .)

If you intend a and b to stand for real numbers, then

(12:07) gp > norm(a+b*I)
%1 = a^2 + b^2

does what you seem to want:  compute the square of the
absolute value.  If a and b can themselves be complex
(or if they are indeterminates which can take values
in any old commutative ring containing something which
behaves like I),  there is no simple formula - the answer
would depend both on the ring you're working in and on
the precise shape of a and b written as elements of that

Enjoy, Gerhard