How to calculate sin/cos/tan of a Quaternion? I would like to learn about Quaternions. I've read this article: https://en.wikipedia.org/wiki/Quaternion
Most of the article was not hard to understand, except the (Exponential, logarithm, and power) part.
To calculate the exponential, I have to calculate sin/cos of the imaginary part, but that functions aren't defined on Quaternions (in the article).
 A: As you can see in the answer cited in the comment, the exponential of a quaternion $z=a+b\mathbf{i}+c\mathbf{j}+d\mathbf{k} = a+\mathbf{v}$, is:
$$
e^z = e^{a+\mathbf{v}}=e^a \left(  \cos  |\mathbf{v}| +\dfrac{\mathbf{v}}{|\mathbf{v}|} \,\sin |\mathbf{v}| \right)
$$
where $|\mathbf v|= \sqrt{b^2+c^2+d^2}$ is a real number  (the modulus of $\mathbf v$), so $\cos  |\mathbf{v}|$ and $ \sin  |\mathbf{v}|$ are well known trigonometric function of a real number, and they have nothing to do with $\cos$ and $\sin$ of a quaternion.
Such ''trigonometric function'' of a quaternion can be defined using a series expansion, in an analogous way than the exponential function because also these series are absolutely convergent, but non commutativity of quaternions gives some troubles about the properties of such functions.
A: Given a quaternion q
To calculate exp(q) the trig functions of quaternions are not necessary.
But if you did want to find a trig function of q:
The first way is the Taylor series for said trig function. Even python can handle the first 15 digits in about 0.005 seconds for small values.
The second way is to use the polar form of the quaternion.
First, we should start with trig of complex numbers:
cos(xi)=cosh(x)

sin(xi)=i sinh(x)

tan(xi)=i tanh(x)

so...
cos(a+bi) = cos(a) cosh(b) - i sin(a) sinh(b)

Expanding this for quaternions:
cos(xj)=cosh(x)

sin(xj)=j sinh(x)

tan(xj)=j tanh(x)

cos(xk)= cosh(x)

sin(xk)=k sinh(x)

tan(xk)=k tanh(x)

Polar form for quaternions uses three variables, which I will denote as r, p, and n.
q = a+bi+cd+dj = a+v = r(cos(p)+n sin(p))
r = abs(q)
p = arccos(a/r)
n = v/abs(v)
r is the distance from 0.
p is the angle from 0
n is the direction of the angle
This is can be expanded for any versor (a quaternion q with abs(q) = 1) n with no real part:
cos(xn) = cosh(x)

sin(xn) = n cosh(x)

So the cosine can be gotten from the polar form of any quaternion:
From a python quaternion-processing code I wrote:
    def __cos__(q, /):
        '''return cos of self in radians'''
        r, p, n = q.__polar__()
        return cos(q.real)*cosh(r*sin(p))-n*sin(q.real)*sinh(r*sin(p))

And in math-language:
a = r(cos(p)

cos(q)

= cos(r(cos(p)+n sin(p)))

= cos(a+n*sin(p))

= cos(a) cos(n r sin(p)) - sin(a) sin(n r sin(p))

= cos(a) cosh(r sin(p)) - n sin(a) sinh(r sin(p))

Python can process this in 0.00015 seconds.
Do the same for the rest of the trig functions to find them.
for cot, sec, and csc...
cot(xi) = coth(x)

sec(xi) = i*sech(x)

csc(ci) = i*csch(s)

and for hyperbolic trig,
cosh(xi) = cos(x)

sinh(xi) = i*sin(x)

tanh(xi) = i*tan(x)

coth(xi) = cot(x)

sech(xi) = i*sec(x)

csch(ci) = i*csc(s)

