Problems defining a function with lists

mrahikka shared this problem 10 months ago
Not a Problem

Using GG Classic 5.0.498.0, the same happens with 6.

I decided to learn quarternions. Wanted to define their product. (the ggb-file is attatched)

p:={3,(1,-2,1)}

q:={2,(-1,2,3)}

The product of quarternions is very complicated expression, so I wanted to create a function to play with them.

First I studied how to calculate the first term in product, it is p(1)*q(1) = 6, it works OK. Then the function:

Tu(a,b):=a(1)*b(1)

->Tu(a, b):=a(1) * b(1)

But when I use it, I will get a list

Tu(p,q)

->{6, (-2)}

Why is it a list and where did -2 come from?

Comments (3)

photo
1

Hi mrahikka!

Your product Tu(p,q) is the same as p*q and GG interprets it as product of the first component and the second component with each other:

So Tu(p,q)={3,(1,-2,1)}*{2,(-1,2,3)}={3*2,(1,-2,1)*(-1,2,3)}={6,-1*1+2*(-2)+3*1}={6,-2}

GG does not know, that a and b in the definition of your function Tu(a,b) are not numbers, but of the form a=(a1,(a2,a3,a4)) with ak real numbers, so it interprets a and a(1) as real number.


One way to define your product is using this: https://en.wikipedia.org/wi...


Take a look at the attached file.

Hope that helps you and kind regards

mire2

photo
1

Yes, I am forgetful ... and in addition to I think you have to replace in the second component cross(Element(p,2),(Element(q,2)) by: cross(vector(Element(p,2)),vector((Element(q,2)))

Hope that it is now correct.

photo
1

thanks

photo
© 2019 International GeoGebra Institute