Quaternion
Exponential, logarithm, and power functions

Given a quaternion,

q = a + b i + c j + d k = a + v, {\displaystyle q=a+b\mathbf {i} +c\mathbf {j} +d\mathbf {k} =a+\mathbf {v},}

the exponential is computed as

exp (q) = ∑ n = 0 ∞ q n n ! = e a (cos ‖ v ‖ + v ‖ v ‖ sin ‖ v ‖), {\displaystyle \exp(q)=\sum _{n=0}^{\infty }{\frac {q^{n}}{n!}}=e^{a}\left(\cos \|\mathbf {v} \|+{\frac {\mathbf {v} }{\|\mathbf {v} \|}}\sin \|\mathbf {v} \|\right),}

and the logarithm is

ln (q) = ln ‖ q ‖ + v ‖ v ‖ arccos a ‖ q ‖. {\displaystyle \ln(q)=\ln \|q\|+{\frac {\mathbf {v} }{\|\mathbf {v} \|}}\arccos {\frac {a}{\|q\|}}.}

It follows that the polar decomposition of a quaternion may be written

q = ‖ q ‖ e n ^ φ = ‖ q ‖ (cos (φ) + n ^ sin (φ)), {\displaystyle q=\|q\|e^{{\hat {n}}\varphi }=\|q\|\left(\cos(\varphi)+{\hat {n}}\sin(\varphi)\right),}

where the angle φ {\displaystyle \varphi }

a = ‖ q ‖ cos (φ) {\displaystyle a=\|q\|\cos(\varphi)}

and the unit vector n ^ {\displaystyle {\hat {n}}} is defined by:

v = n ^ ‖ v ‖ = n ^ ‖ q ‖ sin (φ). {\displaystyle \mathbf {v} ={\hat {n}}\|\mathbf {v} \|={\hat {n}}\|q\|\sin(\varphi)\,.}

Any unit quaternion may be expressed in polar form as:

q = exp (n ^ φ). {\displaystyle q=\exp {({\hat {n}}\varphi)}.}

The power of a quaternion raised to an arbitrary (real) exponent x is given by:

q x = ‖ q ‖ x e n ^ x φ = ‖ q ‖ x (cos (x φ) + n ^ sin (x φ)). {\displaystyle q^{x}=\|q\|^{x}e^{{\hat {n}}x\varphi }=\|q\|^{x}\left(\cos(x\varphi)+{\hat {n}}\,\sin(x\varphi)\right)~.}
oulipo:avoid_letter[a], startend:end_checker