Talk:Quaternion type: Difference between revisions

From Rosetta Code
Content added Content deleted
(→‎ooRexx: new section)
mNo edit summary
Line 84: Line 84:
</lang>
</lang>
be equivalent of "\="
be equivalent of "\="

and why not distinguish = and == ??
::method "=" -- this is equivalent of "==" forward message("==")


--[[User:Walterpachl|Walterpachl]] 07:18, 15 July 2012 (UTC)
--[[User:Walterpachl|Walterpachl]] 07:18, 15 July 2012 (UTC)

Revision as of 07:25, 15 July 2012

Why a draft project?

Because I am unsure if the topic is right for RC. I tried to approach it in such a way that people could just implement what is stated in the task description without going to even the depths of the Wikipedia article. --Paddy3118 13:24, 3 August 2010 (UTC)

Just by the discussion that popped up, I think it's a worthwhile task for illustrating differences between correct imaginary and quaternary operations, and I'd think an 8-class task would be interesting (if complicated), too. (And now everyone at this GURPS session is waiting for me to pay attention.) --Michael Mol 23:01, 3 August 2010 (UTC)
It sounds interesting. Out of curiosity, can it be generalized to N real and M imaginary dimensions? ISTR there was a task that got played and adjusted to various dimension sets. I don't remember the name off-hand. (Hm. It occurs to me that we can create relationships between tasks such as "generalization of::some other task". That strikes me as an interesting direction to explore.) --Michael Mol 15:24, 3 August 2010 (UTC)
In short: no.
First, only certain values of N and M "work". Complex numbers would be N=2 and M=0 OR N=1 and M=1. Quaternions would be N=4 OR N=2 and M=2 OR N=1 and M=3 (depending on exactly what you meant by "imaginary dimensions"). But you can not do anything non-trivially useful with N=3 and M=0 (nor N=1 and M=2). To my knowledge, only 1, 2, 4 and 8 dimensions work here with this kind of arithmetic.
But also, quaternions, and other Cayley–Dickson classes of numbers, are not a full generalization of simpler numbers. Complex numbers do not have some properties which real numbers have. (For example, complex numbers can not be ordered on a line.) Quaternions do not have some properties which complex numbers have (for example quaternion multiplication is not commutative). Octonions lose some properties which quaternions have (for example: octonion multiplication is not associative). So you have to decide if you are willing to deal with the problems introduced by the additional dimensions. (And even that can be risky: I have seen too many mathematical "proofs" which assume that quaternion multiplication is commutative -- which means they are about as meaningful as proofs which assume that 0 divided by 0 is unique.) --Rdm 19:42, 3 August 2010 (UTC)
Mm. So we're talking about N and M needing to be powers of 2? (I haven't peeked at NevilleDNZ's link—no time—but that's what's coming to mind.) And that as N and M go up, the operations lose properties. Interesting and weird at the same time; it suggests to me that there's a way to linearly map a number like N or M to a property set and make prediction, but I think it ought to be getting obvious I never went very far in higher math. :-| Very, very interesting info, though. --Michael Mol 22:58, 3 August 2010 (UTC)
Actually, if we want to stick with the most obvious meanings, N=1 and M is an element of the set {0, 1, 3, 7}. That is, M must be less than 8 and must be 1 less than a positive integral power of 2. However, The Cayley-Dickson approach might let us argue about degrees of imaginaryness, and we can represent quaternions (and so on) with or without explicit use of imaginary numbers. --Rdm 01:47, 4 August 2010 (UTC)
Hi Michael, The wp article does mention Octonians, and I also read wp:Division algebra enough to know that from reals to complex to quaternions to octonians; things seem to get a little less useful. The octonians seeming to have 480 ways to multiply for example. --Paddy3118 16:28, 3 August 2010 (UTC)
I was thinking more along the lines of the kind of code generalization that would allow the same code to operate correctly on any >=0 integer value for M and N. Granted, we're delving outside a simple task. My curiosity there lies being able to learn the relationship by studying the code. --Michael Mol 18:05, 3 August 2010 (UTC)

re: Out of curiosity, can it be generalized to N real and M imaginary dimensions?

There is an interesting generalisation called Clifford algebras which contains a useful subset for Algebra of physical space and Spacetime algebra etc. eg:

  1. Special Relativity
  2. Classical Electrodynamics
  3. Relativistic Quantum Mechanics
  4. Classical Spinor

NevilleDNZ 19:24, 3 August 2010 (UTC)

What simple properties should become part of the task?

Well it seems that enough people like the draft task!

Before I remove the draft status, are their anyother simple properties of quaternions (ore fewer), that the task should ask be shown? --Paddy3118 04:24, 4 August 2010 (UTC)

This is just a personal preference, in preference to a simple 1+1=2 test I prefer - if possible - tests that are a little but more extensive.

For example for the Rational Arithmetic test:

Use the new type frac[tion] to find all perfect numbers less then 219 by summing the reciprocal of the factors.

Basically this test is nice because runs the gauntlet of multiple additions and divisions to come up with a known result.

With compl[ex] numbers such a test could be to check that exp(πi)=-1. Maybe there an equivalent for Quaternions?

NevilleDNZ 05:16, 4 August 2010 (UTC)

As I understand it, unit quaternions are used to model rotations. Perhaps using them to model some kind of rotation would do as a “demonstration” question? –Donal Fellows 07:20, 4 August 2010 (UTC)
Hmm, there is sample pseudo-code and Python here. --Paddy3118 10:40, 4 August 2010 (UTC)

ADA Issue?

Hi, value r should be a floating point number rather than a quaternion without imaginary parts. If you then have to convert r to a quaternion to do the task then that should be shown. --Paddy3118 18:21, 6 August 2010 (UTC) And the same applies to Algol 68. --Paddy3118 18:23, 6 August 2010 (UTC)

Thanks. You are right, I just copied the test from Algol. Fixed. --Dmitry-kazakov 18:31, 6 August 2010 (UTC)
Thank you Dmitry. --Paddy3118 18:40, 6 August 2010 (UTC)

Name

The name of this task seems over-qualified. What does everyone think of renaming it to "Quaternion", "Quaternions", or "Quaternion type"? —Kevin Reid 19:50, 3 February 2011 (UTC)

Doh! It seems so necessary now you brought it up. I moved it. --Paddy3118 20:03, 3 February 2011 (UTC)

E language limitations

The E example has a couple of comments of the form: <lang e> # Task requirement 6, 7

       # This implements q * r; r * q is deliberately prohibited by E</lang>

I was wondering if these are truly language limitations or are they just limitations of this particular implementation? --Paddy3118 00:09, 10 March 2011 (UTC)

Ruby and subtraction

It seems from comments in the template added to the Ruby example, that the Ruby example:

  1. Performs all that is asked for in the task description.
  2. Fails when a quaternion is subtracted from a real. This not being asked of by the task.

What to do? I would vote for there not being any information on this added to the languages entry, but a note on its limitations could be added here in the talk page. My reason is that there are other operations on quaternions that are not mentioned as part of the task and I would not want their ommision cluttering the task page either.

Some might argue that this particular omission is sufficiently close to what is asked for in the task. Yea, it's close; but where to draw a line?

Comments please. --Paddy3118 12:28, 8 May 2011 (UTC)

I agree that failures in the general sense which are not failures to meet the task need to be treated differently from failures to satisfy the task. Perhaps we could get a "bug but acceptable by task requirements" template to mark them? --Rdm

ooRexx

Beautiful, BUT shouldn't <lang rexx>

method "><"
 -- this is equivalent of "\=="
 forward message("\==")

</lang> be equivalent of "\="

and why not distinguish = and == ??

method "=" -- this is equivalent of "==" forward message("==")

--Walterpachl 07:18, 15 July 2012 (UTC)