Associated Topics || Dr. Math Home || Search Dr. Math

### Quaternion Numbers

```
Date: 01/23/97 at 16:28:40
From: Terry W. Gintz
Subject: Quaternion division and transcendental functions

Hi,

Presumably, when William Hamilton discovered quaternions (sometime in
the 1830s), he must have gone further than just multiplying them.  I'm
very interested in how quaternion division is accomplished (from my
experience with complex numbers, first you have to find the inverse of
the divisor, then multiply the dividend by that. But how to find the
inverse of a quaternion number?  Can you do this in basic algebraic
terms, please?  My knowledge of calculus is mainly differential.)

I'm also interested in whether quaternion math can be extended to
transcendental functions like trig and exponential functions.

My main use of the above info will be to implement extended 3D
quaternion plotting in my program ZPlot.  It already plots formulas
like q^2+c and cq^2-1 very nicely, but I'd like to see what q^e+c
looks like, etc.

Terry W. Gintz
```

```
Date: 01/23/97 at 16:58:05
From: Doctor Wilkinson
Subject: Re: Quaternion division and transcendental functions

I am not an expert on quaternions, and don't know the answer to your
second question, but I do know how do divide quaternions.  It's just
like with complex numbers.  If you multiply a + bi + cj + dk
by a - bi -cj - dk, you get a^2 + b^2 + c^2 +d^2, as you can verify
quite easily,  The rules ij = -ji = k, etc. make everything work out
beautifully.  You can use this to clear quaternions out of the
denominators.

-Doctor Wilkinson,  The Math Forum
Check out our web site!  http://mathforum.org/dr.math/
```

```
Date: 01/24/97 at 14:36:25
From: Doctor Toby
Subject: Re: Quaternion division and transcendental functions

Another doctor has already told you about dividing quaternions, so I
will talk about trigonometric and exponential functions.

If you continue to take calculus, you'll probably learn about these
functions in the context of infinite series (if you haven't already).
To calculate exp x = e^x, add up x^n/n! for all natural numbers n
(including n = 0), where n! = the factorial of n = n*(n-1)*...*2*1.
That is, exp x = x^0/0! + x^1/1! + x^2/2! + ....  (Note that 0! = 1,
and x^0 = 1 no matter what x is, even if x = 0.)  The series for cos x
is the sum of (-1)^n x^2n/(2n)!, and the series for sin x is the sum
of (-1)^n x^(2n+1)/(2n+1)!.  Using these series, you can calculate for
yourself that exp ix = cos x + i sin x in the complex numbers.

(There are many technical issues connected with infinite series that
you will learn about if you take a course on them.  It so happens that
the series I will discuss here have no technical difficulties
whatsoever in the real, complex, or quaternion numbers.  So you don't
have to worry about the technical issues; any manipulation you
normally would do with a finite sum is perfectly legitimate with these
infinite sums.)

It is traditional to use the infinite series for exp, cos, and sin as
*definitions* of these functions in nonreal contexts. In particular,
we may take these series as definitions in the quaternions.  I will
examine exp in the quaternions in some detail.

Using the series for exp and the binomial theorem, you can prove the
identity: exp (a + b) = exp a * exp b for real and complex numbers,
because these numbers commute. (x * y = y * x for all real or complex
x and y.)  This identity does *not* hold in the quaternion numbers.
For example, exp (i + j) = cos sqrt 2 + (i + j)(sin sqrt 2)/sqrt 2,
while exp i * exp j = (cos 1)^2 + (i + j)(sin 2)/2 + k(sin 1)^2, and
exp j * exp i = (cos 1)^2 + (i + j)(sin 2)/2 - k(sin 1)^2.  However,
whenever ab = ba (for example, whenever a is real), then
exp (a + b) = exp a * exp b does hold in the quaternions.

That fact is the secret to calculating exp (a + ib + jc + kd).  Since
a commutes with ib + jc + kd (when a, b, c, and d are real),
exp (a + ib + jc + kd) = exp a * exp (ib + jc + kd). Now, you can't
break exp (ib + jc + kd) into exp ib * exp jc * exp kd, but you don't
need to.  Simply divide this vector by its magnitude. The quantity
L = (ib + jc + kd)/sqrt (b^2 + c^2 + d^2) satisfies L^2 = -1 (check it
for yourself).  And you can go back to the infinite series to see that
exp Lx = cos x + L sin x, whenever L^2 = -1 and x is real.  So let
M = sqrt (b^2 + c^2 + d^2), so ib + jc + kd = LM.  Then
exp (a + ib + jc + kd) = exp a (cos M + L sin M).

Now, in order to raise quaternions to arbitrary powers, you'll also
have to calculate their logarithms.  You do this by accepting x as the
logarithm of y whenever exp x = y.  Just as you can write a complex
number in the form r(cos t + i sin t), you can write any quaternion in
the form r(cos M + L sin M), for some real r and M and some vector L
satisfying L^2 = -1.  The logarithm of r(cos M + L sin M) is of course
ln r + LM, where ln is the natural logarithm in the real numbers.  Of
course, you can add any integer multiple of 2 pi to M, so the
logarithm is unique only up to integer multiples of 2 pi L. The
logarithm of a real number is particularly non-unique.  Since the real
number r equals r(cos M + L sin M) for *any* L satisfying L^2 = -1
(when M is a multiple of 2 pi), the logarithm of r can be any
ln r + LM.  For example, the logarithm of 2 can be ln 2 + 2i pi,
ln 2 - 4 k pi, ln 2 + 2 (i + j) pi/sqrt 2, and so on.

At any rate, the definition of x^y is exp (y log x), where log x can
take the value of any logarithm of x.  If n is an integer,
exp (n log x) can take only one value, no matter what value is chosen
for log x, and this agrees with the usual definition of x^n.  Now you
should be able to calculate q^e+c.

As for the trigonometric functions, the infinite series will give you
the common complex formulae cos x = (exp ix + exp -ix)/2 and
sin x = (exp ix - exp -ix)/2i.  These formulae can be derived in the
same way for quaternions, if you replace i by the appropriate value of
L for the quaternion x.  The other trigonometric functions can be
defined in terms of cos and sin.

If you have any more questions, feel free to write back!

-Doctor Toby,  The Math Forum
Check out our web site!  http://mathforum.org/dr.math/
```

```
Date: 01/24/97 at 20:35:14
From: Doctor Toby
Subject: Re: Quaternion division and transcendental functions

I neglected to mention that you can differentiate quaternion
functions. Use the same definition in terms of limits as for complex
functions. The proofs of the sum, product and chain rules go through
unchanged. (Be sure to put the products in the right order.) You can
differentiate the series for exp, sin, and cos to calculate
exp' = exp, sin' = cos, and cos' = -sin; these formulas work just as
well in the quaternions as anywhere else. (This process of
differentiating a series by differentiating its terms is one of the
trickiest when there are technical difficulties. Luckily, you don't
have them with these series.)

Note also that the summation formulas for trigonometric functions
sin(a + b) = (sin a)cos b + (cos a)sin b and
cos(a + b) = (cos a)cos b - (sin a)sin b work only when a and b
commute.  This applies to all the formulas related to these summation
formulas, such as half angle formulas and so on. In general, go back
to the series to check if an identity holds. (They're usually pretty
easy to prove from the series when they do.)

-Doctor Toby,  The Math Forum
Check out our web site!  http://mathforum.org/dr.math/
```

```
Date: 01/24/97 at 20:46:14
From: Terry W. Gintz
Subject: Quaternion division

Thanks for the info.  If I understand this right, in order to divide
quaternions you multiply by the reciprocal of the denominator, which
should be (a-bi-cj-dk)/t where t = a^2+b^2+c^2+d^2.  Simplifying, the
quaternion reciprical is a/t -bi/t -cj/t -dk/t, which is clearly the
logical extention to the complex reciprocal a/t -bi/t, where
t = a^2+b^2.

I am trying out the new quaternion formulas in my program ZPlot now,
and seeing a lot of new shapes too! Thanks very much for the
direction. The exponential q function seems to work well, but the
sin(q) formula didn't seem to work right using exponentials.

I tried coding the formula for sine but the resulting 3D shape didn't
come close to resembling the 2D Julia sine set, and the time to
compute (exp Lx - exp -Lx)/2L was astronomical.  So I switched to an
alternate formula, one I derived from the formula I usually use for
computing complex sine (faster than the exponential form):
sin x cosh M + L cos x sinh M. This gives 3D results with a shape that
closely resembles the 2D Julia set, so I guess I got the derivation
right.  Thanks again for your help.

Terry W. Gintz
```

```
Date: 01/30/97 at 21:59:44
From: Doctor Toby
Subject: Re: Quaternion division and transcendental functions

You're right about how to divide quaternions.  I double-checked your
formula, and it looks correct to me.

For a moment, I thought you were going to ask if I knew any
alternative formulas for the sine that might compute faster, and I'd
have had to say I don't know very well what computes quickly or
slowly.  But now you've given me the formula! So now I can tell it to
anyone who asks with your question again, so they can compute quickly
right away.  Thanks and good luck!

-Doctor Toby,  The Math Forum
Check out our web site!  http://mathforum.org/dr.math/
```
Associated Topics:
College Calculus
College Modern Algebra

Search the Dr. Math Library:

 Find items containing (put spaces between keywords):   Click only once for faster results: [ Choose "whole words" when searching for a word like age.] all keywords, in any order at least one, that exact phrase parts of words whole words

Submit your own question to Dr. Math
Math Forum Home || Math Library || Quick Reference || Math Forum Search