octave-bug-tracker
[Top][All Lists]
Advanced

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

[Octave-bug-tracker] [bug #66652] Element power operator introduces nume


From: Dmitri A. Sergatskov
Subject: [Octave-bug-tracker] [bug #66652] Element power operator introduces numerical error when broadcasting
Date: Fri, 10 Jan 2025 14:18:35 -0500 (EST)

Follow-up Comment #2, bug #66652 (group octave):

On MacOS octave 10 there is no difference:

octave:1> # exponent vector
p = [2 1 0]

# scalar .^ vector is correct
x = i .^ p, x - round(x)
x = (2i) .^ p, x - round(x)
x = (3i) .^ p, x - round(x)

# column vector .^ row vector has numerical error
x = [i; 2i; 3i] .^ p, x - round(x)

# expanding vectors to full matrix is correct again
x = [i i i; 2i 2i 2i; 3i 3i 3i] .^ [2 1 0; 2 1 0; 2 1 0]
x - round (x)
p =

   2   1   0

x =

  -1.0000 + 0.0000i   0.0000 + 1.0000i   1.0000 +      0i

ans =

            0 + 1.2246e-16i   6.1232e-17 +          0i            0 +
0i

x =

  -4.0000 + 0.0000i   0.0000 + 2.0000i   1.0000 +      0i

ans =

            0 + 4.8986e-16i   1.2246e-16 +          0i            0 +
0i

x =

  -9.0000 + 0.0000i   0.0000 + 3.0000i   1.0000 +      0i

ans =

  -1.7764e-15 + 1.1022e-15i   1.8370e-16 + 4.4409e-16i            0 +
0i

x =

  -1.0000 + 0.0000i   0.0000 + 1.0000i   1.0000 +      0i
  -4.0000 + 0.0000i   0.0000 + 2.0000i   1.0000 +      0i
  -9.0000 + 0.0000i   0.0000 + 3.0000i   1.0000 +      0i

ans =

            0 + 1.2246e-16i   6.1232e-17 +          0i            0 +
0i
            0 + 4.8986e-16i   1.2246e-16 +          0i            0 +
0i
  -1.7764e-15 + 1.1022e-15i   1.8370e-16 + 4.4409e-16i            0 +
0i

x =

  -1.0000 + 0.0000i   0.0000 + 1.0000i   1.0000 +      0i
  -4.0000 + 0.0000i   0.0000 + 2.0000i   1.0000 +      0i
  -9.0000 + 0.0000i   0.0000 + 3.0000i   1.0000 +      0i

ans =

            0 + 1.2246e-16i   6.1232e-17 +          0i            0 +
0i
            0 + 4.8986e-16i   1.2246e-16 +          0i            0 +
0i
  -1.7764e-15 + 1.1022e-15i   1.8370e-16 + 4.4409e-16i            0 +
0i

octave:8> x = [i i i; 2i 2i 2i; 3i 3i 3i] .^ [2 1 0; 2 1 0; 2 1 0], x - round
(x)
x =

  -1.0000 + 0.0000i   0.0000 + 1.0000i   1.0000 +      0i
  -4.0000 + 0.0000i   0.0000 + 2.0000i   1.0000 +      0i
  -9.0000 + 0.0000i   0.0000 + 3.0000i   1.0000 +      0i

ans =

            0 + 1.2246e-16i   6.1232e-17 +          0i            0 +
0i
            0 + 4.8986e-16i   1.2246e-16 +          0i            0 +
0i
  -1.7764e-15 + 1.1022e-15i   1.8370e-16 + 4.4409e-16i            0 +
0i

octave:9> x = [i; 2i; 3i] .^ [2 1 0], x - round (x)
x =

  -1.0000 + 0.0000i   0.0000 + 1.0000i   1.0000 +      0i
  -4.0000 + 0.0000i   0.0000 + 2.0000i   1.0000 +      0i
  -9.0000 + 0.0000i   0.0000 + 3.0000i   1.0000 +      0i

ans =

            0 + 1.2246e-16i   6.1232e-17 +          0i            0 +
0i
            0 + 4.8986e-16i   1.2246e-16 +          0i            0 +
0i
  -1.7764e-15 + 1.1022e-15i   1.8370e-16 + 4.4409e-16i            0 +
0i

octave:10> 


Dmitri.
-- 




    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?66652>

_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/

Attachment: signature.asc
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]