Talk:Geometric algebra
This is maybe too big for a task
I'm pretty sure people will say that, and maybe they're right. But maybe not. I don't think it is much more complicated than say Quaternion type, and in any case it is, from both the programming and mathematical points of view,, quite interesting and worth featuring in Rosetta Code, imho. Please feel free to argue about it.--Grondilu (talk) 22:38, 13 October 2015 (UTC)
- It's not clear that we can meaningfully implement anything with infinite dimension - countable or not. At best, we can support a finite subset of such a thing.
- More specifically, how would we tell whether an implementation has or has not satisfied that part of the task requirement? --Rdm (talk) 12:36, 14 October 2015 (UTC)
- It's infinite in the sense that there is no limit to the number of dimensions. But we only consider vectors that have a finite support. I guess I could mention that, indeed. It's also true that it's not obvious how we can check that an implementation can handle any vector size. I welcome suggestions.--Grondilu (talk) 15:56, 14 October 2015 (UTC)
- I would describe that as an arbitrary number of dimensions rather than an infinite number of dimensions (edit: and I see that you have made exactly that change in the task description). But that brings up another issue: - unless we severely constrain our work, how are we going to verify that an implementation has satisfied this task in that regard? --Rdm (talk) 16:25, 14 October 2015 (UTC)
- That might be a bit overly constrained? Though, granted, not constrained enough for the "forall" test to be implemented - which, I guess, is why you made the test for correctness be a single case? See also Quaternion type for quaternion implementations... --Rdm (talk) 12:45, 17 October 2015 (UTC)
- I see that you posted a solution using the quaternion task. That is obviously not what was intended. You're supposed to implement the geometric algebra and use it to implement quaternions. Implementing quaternions is not the purpose per se.--Grondilu (talk) 16:14, 17 October 2015 (UTC)
- I believe I have changed that implementation to satisfy the requirement of the "incorrect" notice. That said, I will also note that I believe this issue could be stated significantly more clearly in the task description with relatively little effort. --Rdm (talk) 17:42, 17 October 2015 (UTC)
- I think it is pretty clear already that the quaternion data structure is meant only as a show-case for the use of geometric algebra. Using an implementation of quaternions that does not actually implement geometric algebra can not be satisfactory. If you persist I guess I will have to switch back to verifying axioms.--Grondilu (talk) 17:58, 17 October 2015 (UTC)
- Whatever you do, please be sure you understand the requirements stated in the add a task page. You should only expect implementations to satisfy those parts of the task description which are valid for a task description. --Rdm (talk) 18:03, 17 October 2015 (UTC)
- You removed the incorrect banner, but didn't you write that the first element of this structure is the real component? If so, e2 defined with 1 0 0 0 is a scalar, not a vector. In any case it is not orthonormal with the e1 and e3. I will add the creation of a function e(n), along with an orthonormality test, as a requirement to clarify that.--Grondilu (talk) 18:12, 17 October 2015 (UTC)
- I think you are confused.
- So... let's review: a quaternion consists of four orthogonal components. What you term the "scalar part" is a part of an orthonormal basis for quaternions. --Rdm (talk) 18:30, 17 October 2015 (UTC)
- A scalar is not orthogonal to a vector.--Grondilu (talk) 18:40, 17 October 2015 (UTC)
- Except we are working with quaternions, and the "scalar part of a quaternion" is indeed orthogonal to any "vector part of a quaternion". --Rdm (talk) 18:57, 17 October 2015 (UTC)
- I'm not sure what you mean by orthogonal here, because there is no scalar product in the space of quaternions. I did define a scalar product for the purpose of this task, and with this scalar product, a scalar is not orthogonal with a vector, because it commutes with all vectors. For instance 2i + i2 is not 0.--Grondilu (talk) 19:05, 17 October 2015 (UTC)
- Except you did not define what you mean by "the symmetric part" of the quaternion. --Rdm (talk) 19:14, 17 October 2015 (UTC)
- I'm not sure what you mean by orthogonal here, because there is no scalar product in the space of quaternions. I did define a scalar product for the purpose of this task, and with this scalar product, a scalar is not orthogonal with a vector, because it commutes with all vectors. For instance 2i + i2 is not 0.--Grondilu (talk) 19:05, 17 October 2015 (UTC)
- Except we are working with quaternions, and the "scalar part of a quaternion" is indeed orthogonal to any "vector part of a quaternion". --Rdm (talk) 18:57, 17 October 2015 (UTC)
- A scalar is not orthogonal to a vector.--Grondilu (talk) 18:40, 17 October 2015 (UTC)
- You removed the incorrect banner, but didn't you write that the first element of this structure is the real component? If so, e2 defined with 1 0 0 0 is a scalar, not a vector. In any case it is not orthonormal with the e1 and e3. I will add the creation of a function e(n), along with an orthonormality test, as a requirement to clarify that.--Grondilu (talk) 18:12, 17 October 2015 (UTC)
- Whatever you do, please be sure you understand the requirements stated in the add a task page. You should only expect implementations to satisfy those parts of the task description which are valid for a task description. --Rdm (talk) 18:03, 17 October 2015 (UTC)
- I think it is pretty clear already that the quaternion data structure is meant only as a show-case for the use of geometric algebra. Using an implementation of quaternions that does not actually implement geometric algebra can not be satisfactory. If you persist I guess I will have to switch back to verifying axioms.--Grondilu (talk) 17:58, 17 October 2015 (UTC)
- I believe I have changed that implementation to satisfy the requirement of the "incorrect" notice. That said, I will also note that I believe this issue could be stated significantly more clearly in the task description with relatively little effort. --Rdm (talk) 17:42, 17 October 2015 (UTC)
- I see that you posted a solution using the quaternion task. That is obviously not what was intended. You're supposed to implement the geometric algebra and use it to implement quaternions. Implementing quaternions is not the purpose per se.--Grondilu (talk) 16:14, 17 October 2015 (UTC)
- That might be a bit overly constrained? Though, granted, not constrained enough for the "forall" test to be implemented - which, I guess, is why you made the test for correctness be a single case? See also Quaternion type for quaternion implementations... --Rdm (talk) 12:45, 17 October 2015 (UTC)
J's orthonormality expression.
The J expression 0 1 2 3 dot&e"0/0 1 2 3
generates a table of 16 dot products.
Breaking this down:
The left argument is 0 1 2 3, and the right argument is 0 1 2 3. each row corresponds to an item from the left argument (the first row corresponding to the first item from the left argument, the last row corresponding to the last item from the left argument - in other words, rows in the result are in the same order as items in the left argument. Likewise columns in the result correspond to items from the right argument.
In each case, the value in the result is the result of (e left_item) dot (e right_item).
As the result is an identity matrix, we can see that we have an orthonormal basis.
- while you're at it, you can clarify the function e and its output for 1, 2, 3.--Grondilu (talk) 19:08, 17 October 2015 (UTC)
A possible source of confusion
The wikipedia page on Clifford algebra states:
- The basis elements can be identified with the quaternion basis elements i, j, k as
- The basis elements can be identified with the quaternion basis elements i, j, k as
This has a different parity from the current task requirement for i, j and k. --Rdm (talk) 19:01, 17 October 2015 (UTC)
- Well this is not accurate, because with this definition, , not -1.
--Grondilu (talk) 19:12, 17 October 2015 (UTC)
- Unless you have a suitable definition for
e
.
- Unless you have a suitable definition for
- For example, consider:
- It's necessarily consistent as long as I get the defining property . Regarding the parity difference, Richard Wareham mentions it in his docoral thesis:
- « It is worth comparing this method of rotation to rotation via quaternions. The three bivectors B1, B2 and B3 act identically to the three ‘imaginary’ components of quaternions, i, -j and k respectively. The sign difference between B2 and j is due to the fact that the quaternions are not derived from the usual right-handed orthogonal co-ordinate system. This handedness mismatch often leads to annoying sign errors in quaternion-based algorithms. »
- Computer Graphics Using Conformal Geometric Algebra, page 13. --Grondilu (talk) 20:16, 17 October 2015 (UTC)
- It's not consistent if i, j and k are not orthogonal to each other, which is the case for the javascript implementation (and I do not have a working copy of perl6, so I can't test whether that implementation is invalid or not). It might be that i, j and k are not orthogonal for any implementation which satisfies the constraints in the task description - I suspect that that is the case, but I need to think a bit more to see if I can either (a) find an interpretation of the task description which is internally consistent, or (b) find a way of showing a contradiction. --Rdm (talk) 22:01, 17 October 2015 (UTC)
- i, j and k are not vectors in geometric algebra. They are bivectors. Orthogonality does not apply to them. The formula I gave for the scalar product only stands for vectors (thus the boldface notation which often means "vectors"). Also I've never written they should be orthogonal. It's the e basis that is, not the i, j, k.--Grondilu (talk) 22:24, 17 October 2015 (UTC)
- It's not consistent if i, j and k are not orthogonal to each other, which is the case for the javascript implementation (and I do not have a working copy of perl6, so I can't test whether that implementation is invalid or not). It might be that i, j and k are not orthogonal for any implementation which satisfies the constraints in the task description - I suspect that that is the case, but I need to think a bit more to see if I can either (a) find an interpretation of the task description which is internally consistent, or (b) find a way of showing a contradiction. --Rdm (talk) 22:01, 17 October 2015 (UTC)
"Orthonormal basis"
Ok, I'm still trying to figure out what you are asking for here.
But it looks like e(1), e(2) and e(3) are not quaternions.
Is that what you are asking for? A "quaternion multiplication" which also works for something which is not a quaternion, such that when some of those other things are multiplied you can get a quaternion basis? --Rdm (talk) 22:25, 17 October 2015 (UTC)
- I don't know why you thought they were quaternions. They are orthonormal vectors from which the quaternions are made. You make three bivectors i, j and k from these vectors and you verify that those bivectors satisfy the algebraic identity , which means they are isomorphic to the quaternion field.--Grondilu (talk) 22:31, 17 October 2015 (UTC)
Task still needs something...
Re-reading the task, and the implementation you have, I think the task needs some additional qualification.
Specifically, it's entirely possible to satisfy
in a fashion which does not support quaternion multiplication. For example, an algebra where and and would not support quaternions but would completely satisfy the given constraints.
And, in fact, there are arbitrarily many complex rules one could apply to achieve quaternion multiplication and still satisfy those constraints. This means that the specification is incomplete. --Rdm (talk) 22:49, 17 October 2015 (UTC)
- Yes, there are trivial geometric algebras. is an obvious one. But if the vector space is of dimension at least 3, and if no vector is degenerate (), then quaternions can be made. Since I ask for an arbitrary dimension size, there is no need to require more.--Grondilu (talk) 22:56, 17 October 2015 (UTC)
- The specification of geometric algebras is very much complete. I did not invent them.--Grondilu (talk) 22:57, 17 October 2015 (UTC)
- This does not mean that your task description is adequate.
- From a vector space of arbitrary dimension (but at least 3), you can use the geometric product, not the scalar product, to create three bivectors i, j, k such that the subalgebra generated by (1, i, j, k) is isomorphic to the quaternion field. I think that's basically what the task description says. Maybe I could be a bit more verbose, but I think that is not necessary.--Grondilu (talk) 23:07, 17 October 2015 (UTC)
The J solution might be correct but too small
I don't understand much of it, but I suspect it may be correct, considering it uses a 32-dimensions space, which is exactly what you need for the geometric algebra out of a 5-dimensions vector space, because .
However, the required minimal dimension for the vector space was 32, not 5. The tests do not verify that, so I will not flag the J solution as incorrect, but still I think it's worth mentioning. It'd be nice if the solution could be modified in the future to account for a larger vector space.
--Grondilu (talk) 19:23, 18 October 2015 (UTC)
- You're supposed to be able to call e(n) for n from 0 to 31 or more. In other words the vector space is of dimension at least 32. Your implementation does not allow for n > 4. The dimension 32 in your code seems to be the dimension of the algebra, which is .--Grondilu (talk) 20:33, 18 October 2015 (UTC)
- Oh, indeed. That's an error in the javascript code.--Grondilu (talk) 21:24, 18 October 2015 (UTC)
- Or not. You're right the javascript implementation can not go beyond 5 vector dimensions either. My bad. I'll rewrite the task description to relax the requirement on the number of dimensions. It's not the main point of the task, anyway.--Grondilu (talk) 21:29, 18 October 2015 (UTC)
- Jeez changed my mind again. The javascript implementation is definitely wrong. It will be tedious to change it but I will.--Grondilu (talk) 21:35, 18 October 2015 (UTC)
- Done. It was much simpler than I thought.--Grondilu (talk) 21:50, 18 October 2015 (UTC)
Notation
The task decription MUST be coherent with the wikipedia page. A base is (e1 e2 ... en) not (e0 e1 ...en). e0 must be reserved to the scalar part of a multivector. Please state the algebra dimension (2^n) , n=?? in the subtasks definition. --G.Brougnard (talk) 10:04, 19 October 2015 (UTC)
- In this Wikipedia article the indices begin with 1, as is often the case for the notation of basis in linear algebra. However, in computing it's more traditional to begin array indices with 0, for consistency with the C programming language, I suppose. Thus a basis is often implemented as e(0), e(1), e(2) etc. It's not an inconsistency between this particular article and task, it's more a slight notation difference between mathematics and computing.
- So I disagree that we should reserve the 0 index to the scalar part. To me a scalar should be a regular scalar somehow "promoted" to the status of a multivector. In my library I offered a way to create it with a call to e with no argument : e()
- --Grondilu (talk) 15:41, 19 October 2015 (UTC)