<s>[INST] How to convert Quaternions into Polar form? I would like to know how to write quaternions as polar form. Because I heard that if $A$ and $B$ are elements of $C$, this can be done with the form $A \cdot e^{B \cdot j}$.
But how can I do that?
Can I do it like this
$
\begin{align*}
a + b \cdot i + c \cdot j + d \cdot k &= \sqrt{\left( a + b \cdot i \right)^{2} + \left( c + d \cdot i \right))^{2}} \cdot \exp\left( \tan^{-1}\left( \frac{c + d \cdot i}{a + b \cdot i} \right) \cdot j \right)\\
\end{align*}
$?
 [/INST] 
How to convert Quaternions into Polar form?

In general if you have a quaternion $q$ with $ q = q_{w} + q_{x} \cdot \mathrm{i} + q_{y} \cdot \mathrm{j} + q_{z} \cdot \mathrm{k} $, you can write it as $ q = \left| q \right| \cdot \exp\left( \theta \cdot \left( \cos\left( \varphi_{x} \right) \cdot \mathrm{i} + \cos\left( \varphi_{y} \right) \cdot \mathrm{j} + \cos\left( \varphi_{z} \right) \cdot \mathrm{k} \right) \right) $ where $ \left| q \right| = \sqrt{q_{w}^{2} + q_{x}^{2} + q_{y}^{2} + q_{z}^{2}} $.
We already know from studying quaternions in spatial rotation that $ e^{\theta \cdot \left( u_{x} \cdot \mathrm{i} + u_{y} \cdot \mathrm{j} + u_{z} \cdot \mathrm{k} \right)} = \cos\left( \theta \right) + \left( u_{x} \cdot \mathrm{i} + u_{y} \cdot \mathrm{j} + u_{z} \cdot \mathrm{k} \right) \cdot \sin\left( \theta \right) $ so we get $ q = \left| q \right| \cdot \left( \cos\left( \theta \right) + \left( \cos\left( \varphi_{x} \right) \cdot \mathrm{i} + \cos\left( \varphi_{y} \right) \cdot \mathrm{j} + \cos\left( \varphi_{z} \right) \cdot \mathrm{k} \right) \cdot \sin\left( \theta \right) \right) $.
If we compare the ral parts of both sides of the equation of the quaternion (the one in the algebraic form and the one in the polar form), we get:
$$
\begin{align*}
q = q_{w} + q_{x} \cdot \mathrm{i} + q_{y} \cdot \mathrm{j} + q_{z} \cdot \mathrm{k} ~&\wedge ~q = \left| q \right| \cdot \left( \cos\left( \theta \right) + \left( \cos\left( \varphi_{x} \right) \cdot \mathrm{i} + \cos\left( \varphi_{y} \right) \cdot \mathrm{j} + \cos\left( \varphi_{z} \right) \cdot \mathrm{k} \right) \cdot \sin\left( \theta \right) \right)\\
\end{align*}
$$
$$
\begin{align*}
q_{w} + q_{x} \cdot \mathrm{i} + q_{y} \cdot \mathrm{j} + q_{z} \cdot \mathrm{k} &= \left| q \right| \cdot \left( \cos\left( \theta \right) + \left( \cos\left( \varphi_{x} \right) \cdot \mathrm{i} + \cos\left( \varphi_{y} \right) \cdot \mathrm{j} + \cos\left( \varphi_{z} \right) \cdot \mathrm{k} \right) \cdot \sin\left( \theta \right) \right)\\
q_{w} + q_{x} \cdot \mathrm{i} + q_{y} \cdot \mathrm{j} + q_{z} \cdot \mathrm{k} &= \left| q \right| \cdot \cos\left( \theta \right) + \left| q \right| \cdot \left( \cos\left( \varphi_{x} \right) \cdot \mathrm{i} + \cos\left( \varphi_{y} \right) \cdot \mathrm{j} + \cos\left( \varphi_{z} \right) \cdot \mathrm{k} \right) \cdot \sin\left( \theta \right) \quad\mid\quad \Re\left(  \right)\\
\Re\left( q_{w} + q_{x} \cdot \mathrm{i} + q_{y} \cdot \mathrm{j} + q_{z} \cdot \mathrm{k} \right) &= \Re\left( \left| q \right| \cdot \cos\left( \theta \right) + \left| q \right| \cdot \left( \cos\left( \varphi_{x} \right) \cdot \mathrm{i} + \cos\left( \varphi_{y} \right) \cdot \mathrm{j} + \cos\left( \varphi_{z} \right) \cdot \mathrm{k} \right) \cdot \sin\left( \theta \right) \right)\\
q_{w} &= \left| q \right| \cdot \cos\left( \theta \right) \quad\mid\quad \div \left| q \right|\\
\frac{q_{w}}{\left| q \right|} &= \cos\left( \theta \right) \quad\mid\quad \arccos\left(  \right)\\
\arccos\left( \frac{q_{w}}{\left| q \right|} \right) &= \arccos\left( \cos\left( \theta \right) \right)\\
\arccos\left( \frac{q_{w}}{\left| q \right|} \right) &= \theta\\
\theta &= \arccos\left( \frac{q_{w}}{\left| q \right|} \right)\\
\end{align*}
$$
So all we have to do is $ \varphi_{x} $, $ \varphi_{y} $ and $ \varphi_{z} $ determine.
In fact, we can do this with all components of the quaternions:
$$
\begin{align*}
q_{w} + q_{x} \cdot \mathrm{i} + q_{y} \cdot \mathrm{j} + q_{z} \cdot \mathrm{k} &= \left| q \right| \cdot \left( \cos\left( \theta \right) + \left( \cos\left( \varphi_{x} \right) \cdot \mathrm{i} + \cos\left( \varphi_{y} \right) \cdot \mathrm{j} + \cos\left( \varphi_{z} \right) \cdot \mathrm{k} \right) \cdot \sin\left( \theta \right) \right)\\
q_{w} + q_{x} \cdot \mathrm{i} + q_{y} \cdot \mathrm{j} + q_{z} \cdot \mathrm{k} &= \left| q \right| \cdot \cos\left( \theta \right) + \left| q \right| \cdot \cos\left( \varphi_{x} \right) \cdot \mathrm{i} \cdot \sin\left( \theta \right) + \left| q \right| \cdot \cos\left( \varphi_{y} \right) \cdot \mathrm{j} \cdot \sin\left( \theta \right) + \left| q \right| \cdot \cos\left( \varphi_{z} \right) \cdot \mathrm{k} \cdot \sin\left( \theta \right) \quad\mid\quad \dot\Im\left(  \right)\\
\dot\Im\left( q_{w} + q_{x} \cdot \mathrm{i} + q_{y} \cdot \mathrm{j} + q_{z} \cdot \mathrm{k} \right) &= \dot\Im\left( \left| q \right| \cdot \cos\left( \theta \right) + \left| q \right| \cdot \cos\left( \varphi_{x} \right) \cdot \mathrm{i} \cdot \sin\left( \theta \right) + \left| q \right| \cdot \cos\left( \varphi_{y} \right) \cdot \mathrm{j} \cdot \sin\left( \theta \right) + \left| q \right| \cdot \cos\left( \varphi_{z} \right) \cdot \mathrm{k} \cdot \sin\left( \theta \right) \right)\\
q_{a} &= \cos\left( \varphi_{a} \right) \cdot \sqrt{\left| q \right|^{2} - q_{w}^{2}}\\
q_{a} &= \cos\left( \varphi_{a} \right) \cdot \sqrt{\left| q \right|^{2} - q_{w}^{2}} \quad\mid\quad \div \left( \sqrt{\left| q \right|^{2} - q_{w}^{2}} \right)\\
\frac{q_{a}}{\sqrt{\left| q \right|^{2} - q_{w}^{2}}} &= \cos\left( \varphi_{a} \right) \quad\mid\quad \arccos\left(  \right)\\
\arccos\left( \frac{q_{a}}{\sqrt{\left| q \right|^{2} - q_{w}^{2}}} \right) &= \arccos\left( \cos\left( \varphi_{a} \right) \right)\\
\arccos\left( \frac{q_{a}}{\sqrt{\left| q \right|^{2} - q_{w}^{2}}} \right) &= \varphi_{a}\\
\varphi_{a} &= \arccos\left( \frac{q_{a}}{\sqrt{\left| q \right|^{2} - q_{w}^{2}}} \right)\\
\end{align*}
$$

Can I do it like this $ a + b \cdot i + c \cdot j + d \cdot k = \sqrt{\left( a + b \cdot \mathrm{i} \right)^{2} + \left( c + d \cdot i \right))^{2}} \cdot \exp\left( \tan^{-1}\left( \frac{c + d \cdot \mathrm{i}}{a + b \cdot i} \right) \cdot \mathrm{j} \right) $?

Nope, because the formula is unfortunately not correct.
You can easily disprove the formula with the simple counterexample $ a = 0 = b $:
$$
\begin{align*}
&\text{counterexample } a = 0 = b\\
&\quad 0 + 0 \cdot i + c \cdot j + d \cdot k = \sqrt{\left( 0 + 0 \cdot \mathrm{i} \right)^{2} + \left( c + d \cdot i \right))^{2}} \cdot \exp\left( \tan^{-1}\left( \frac{c + d \cdot \mathrm{i}}{0 + 0 \cdot i} \right) \cdot \mathrm{j} \right)\\
&\quad 0 + 0 \cdot i + c \cdot j + d \cdot k = \sqrt{\left( 0 + 0 \cdot \mathrm{i} \right)^{2} + \left( c + d \cdot i \right))^{2}} \cdot \exp\left( \tan^{-1}\left( \underbrace{\frac{c + d \cdot \mathrm{i}}{0}}_{\text{Division by } 0 \text{ is not defined!}} \right) \cdot \mathrm{j} \right)\\
\end{align*}
$$
But of course also bring quaternions into the polar form $ A \cdot e^{B \cdot \mathrm{j}} $ (which is discussed here).
</s>