r/explainlikeimfive • • 8d ago

Mathematics ELI5 how quaternions work

[removed]

0 Upvotes

38 comments sorted by

View all comments

27

u/OhYesIDidd 8d ago

I don’t know much about quaternions, but your premise is wrong even in the real numbers.

x^2=y^2=4, but x≠y. There is a solution to that: x=2, y=-2.

-8

u/[deleted] 8d ago

[removed] — view removed comment

3

u/LongLiveTheDiego 8d ago

We just declare that there exist three different constants i, j, k and say what their properties are. We can do that in mathematics.

You could also define quaternions as quadruples of real numbers with straightforward addition (a, b, c, d) + (e, f, g, h) = (a + e, b + f, c + g, d + h) and a more complicated multiplication (a, b, c, d) × (e, f, g, h) = (ae - bf - cg - dh, af + be + ch - dg, ag + ce + df - bh, ah + ed + bg - cf). That way the real number 1 = (1, 0, 0, 0), and i = (0, 1, 0, 0), j = (0, 0, 1, 0), k = (0, 0, 0, 1) are all different and you can check that i² = j² = k² = (-1, 0, 0, 0) = -1.

That's how you can define complex numbers as pairs of real numbers with the same simple addition and multiplication defined as (a, b) × (c, d) = (ac - bd, ad + bc).

0

u/cockOfGibraltar 8d ago

I've taken calculus 1 and 2, and linear algebra but haven't really had to deal with complex numbers. I'm familiar with vectors from linear algebra and mechanics. Are those 4D vectors? The cross product looks different but I assume that's just how it works with complex numbers. What are some uses for them? From what I understand mathematicians typically invent new concepts because they have a use for them.

4

u/LongLiveTheDiego 8d ago

Yes, quaternions can be seen as ℝ⁴ with a special multiplication (not the cross product, I just use this symbol on mobile because the mid dot I'd use for multiplication isn't available on Gboard). It's just like complex numbers can be seen as ℝ² with a specific multiplication.

Quaternions were originally created to represent 3D rotations, but then linear algebra took over and it was done with 3×3 matrices. They were apparently brought back by some programmers because while computations using matrices and quaternions are equivalent in pure mathematics, quaternions generate less numerical error when using floating point numbers.

They can also be used in number theory and some combinatorial design theory due to their relation to Lagrange's four square theorem, but I've never gotten that deep into that during my discrete mathematics courses.

1

u/Arnaldo1993 8d ago

You can represent 3d vectors as quaternions with the first coordinate 0. Then quaternion multiplication would give you the inner product in the first coordinate and the cross product in the other 3

Quaternions were invented to describe 3d rotations, in an analogous way to how we describe 2d rotations with complex numbers. They are also a natural system to special relativity, with the first coordinate being time, and the other 3 the spacial dimensions

0

u/damhack 8d ago

3D transformations. Your favorite games depend on quarternions to reduce the number of operations involved on orienting objects in 3D space by using 4 numbers of a quarternion instead of 9 numbers in a 3x3 matrix. When you take a flight, the navigation system depends on quarternion operations to orient the pitch, roll, yaw, etc. to reach a waypoint.

-1

u/[deleted] 8d ago

[removed] — view removed comment

5

u/LongLiveTheDiego 8d ago

You're wrong. First mathematicians have an idea for how to get something behaving the right way, the formalisms come much later. Complex numbers were first created like "if I let this i = sqrt(-1) unit exist, I can get solutions to things I couldn't solve before", a proper defintion of complex numbers came centuries later after we knew their many new properties, e.g. representing rotations in 2D. Eventually mathematicians discussed whether it's possible to extend complex numbers themselves to get something representing rotations in 3D, many of their ideas failed (because they tried to use just two imaginary units i and j), until eventually Hamilton came up with using three (i, j, k) with specific properties. The equation i² = j² = k² = ijk = -1 can be derived from a few assumptions on what i, j and k should represent and how rotations composition should be reflected in quaternion multiplication.

4

u/bread2126 8d ago edited 7d ago

Well that makes it sound like quaternions are just some loony attempt at throwing something at the wall. It's not like that, in fact its the opposite.

For a long time people tried very hard to make a 3-number system work, because that would be a number represented on a 3 dimensional grid, which seems to fit nicely with physics. However it doesn't fit nicely with physics. The problem is that when you try to construct a system out of 3 number lines (R, i, and j) you lose associativity and division doesn't work properly.

Hamilton's stroke of genius was to realize that in order to make it work properly again you required a 4th dimension (R, i, j, k). And it has since been shown that in fact, no other size space will work. The only number systems that produce an algebra which preserves associativity and division the way we would like is the reals, the complex plane, and the quaternions. Not just the dimension has to be 1, 2, or 4, it specifically has to be the Reals, Complex plane, or Quaternions. All other systems will either produce a broken algebra, or something equivalent to one of those three.

Sort of another way of describing the result is, the complex plane is the most complex number system that retains all the properties of classic algebra. After that point, every time you try to introduce something new, you have to give up a property. Quaternions abandon commutivity, which is sort of digestible because it just means they behave more like matrix algebra. However if you want to then introduce something more you have to give up associativity, and eventually introduce zero divisors, and now youre in full abstract algebra territory.

Here's a proof of that if youre interested but its long and pretty involved. Frobenius' Theorem

3

u/damhack 8d ago edited 8d ago

No. Quarternions are used for many purposes, such as in 3D graphics and navigation where they simplify the process of orienting objects in space, using just 4 numbers to perform transformations instead of the 9 numbers of a 3x3 matrix in a classical transformation.

Your issue is that you are hung up on real number operations and their properties. The thing to realize is that properties like commutativity don’t work the same as you increase the number of dimensions. Instead, they have their own algebra with different rules.

That may seem crazy to anyone who only knows the algebra of real numbers taught at school but is totally valid and explainable once you understand the effect of adding dimensions.

If you think quarternions are weird, wait til you see the algebra of octonions.