Questions regarding list multiplication

artydent shared this question 1 week ago
Answered

I have a few questions regarding multiplication of lists.

The online manual mentiones that multiplication of two lists is allowed for matrices with the proper dimensions (then matrix multiplication is applied), or if the two lists have the same number of elements (in which case an element-wise multplication happens).

In CAS mode, some other non-documented list multiplications work as well (e.g. multpliying lists of numbers if different length, in which case the extra elements of the longer list are just ignored).


Q1: Can we assume that all the non-rejected list multiplications in CAS mode have well-defined behaviour? If so, what are the rules?


In another topic we discovered a list multiplication that Geogebra-CAS accepts for some reason, but it has some weird side effects when used with points. It's a multipication of a row vector (e.g. {{a,b,c}}) with a simple list of the same size (e.g. {d,e,f}). Technically those are not two matrices and also not lists if same size, so it's outside the documentation. Testing shows that Geogebra-CAS then treats the simple list somewhat like a column vector and applies matrix multiplication, only that the result is not a 1-1-matrix but a simple 1-element list.

ae49ec20c787b7f4e5a9bf61c7fe0005

Q2: Is this the intended behaviour? Or rather, why is such a multiplication even allowed in the first place?


Now to a weird side effect: If the elements of the simple list are 2D-points then in principle the same matrix multiplication happens, but Geogebra interprets the result differently based on whether the number of elements in the original list was odd or even. For odd-numbered lists, the result is a list containing a single point, exactly as one would expect. For even-numbered lists though, the two coordinated of the resulting point are interpreted as real and imaginary part of a complex number.

24024a40b75f328ecffd568f52d5dedcQ3: Just a bug? Or can someone explain what weird combination of interpretations Geogebra applies here to get to those different results based on odd/even?

Best Answer
photo

If you type "bad" syntax like {{a,b,c}} {d,e,f} then it's not guaranteed what output you'll get. (Ideally it would return "?" but that's not on the roadmap to improve right now)

Comments (2)

photo
1

If you type "bad" syntax like {{a,b,c}} {d,e,f} then it's not guaranteed what output you'll get. (Ideally it would return "?" but that's not on the roadmap to improve right now)

photo
1

Thanks for clarification.

Even though I am somewhat disappointed that Geogebra accepts too much "bad" syntax, I understand that fixing such things isn't high priority.

photo
© 2021 International GeoGebra Institute