Is this a bug when multiplying lists?

Alasdair shared this question 2 years ago
Answered

In the Algebra View:

a = {x+2, x+3, x+4}

b = {5, 10, 15}

a*b

{x + 2*5, x+3*10, x+4*15}

Why does GeoGebra seem to think that the product of x+2 and 5 is x + 10? How can I instruct GeoGebra that the output should be

{5x + 10, 10x + 30, 15x + 60} ?

The correct result is given in the CAS view - so why not in the Algebra View?

Alasdair

Comments (4)

photo
1

You can check it's right with Polynomial(Element(l1,2)) (it's missing brackets when displayed, that's all).


Workaround

Sequence(Element(a, i)*Element(b, i),i,1,3)

or you might like


Sequence(Polynomial(Element(a, i)*Element(b, i)),i,1,3)

photo
1

Or if you don't want to use Sequence and Element, using Zip is nice and short:

Zip(p*n, p, a, n, b)

or

Zip(Polynomial(p*n), p, a, n, b)

if you want it already expanded.


Still a bit weird though that the the list multiplication doesn't work. The elements of the first list seem to be interpreted differently then.

photo
1

Many thanks. I know I can "force" Geogebra to give me the correct answer by creating a sequence that multiples each pair of elements from the initial sequences, but the thing is, I shouldn't have to. Geogebra has the functionality of multiplying two lists directly - so it should work on symbolic lists as well; that is, brackets should be provided in its internal algorithm.

A list multiplication that acts in the way of my initial example is clearly wrong.

photo
1

A list multiplication that acts in the way of my initial example is clearly wrong.
The list are multiplicated OK, It is the text showed in algebra view the wrong thing

© 2023 International GeoGebra Institute