given an angle and an axis, the corresponding quaternion can be computed like this.
$w = \cos( Angle/2)$
$x = \text{axis}.x * \sin( Angle/2 )$
$y = \text{axis}.y * \sin( Angle/2 )$
$z = \text{axis}.z * \sin( Angle/2 )$
My question is, how are they formulas derived? I would like to know where they came from to understand quaternions better.
I'll take a crack at this, hopefully this will shed some light on how this works. First, it's important to remember that if you want to use a quaternion $\bf p$ to rotate some vector, also represented as a quaternion, $\bf a$, then you have to observe some rules.
$\bf a$ is typically represented by a pure imaginary quaternion, that is, $(0, \vec a)$. The rotation, as you observed, is represented by $(c,\vec ps)$, where $\vec p$ is the unit vector representing the axis of rotation, and $c$ and $s$ are the sine and cosine of $\theta/2$.
We'll also take a shortcut and use vector math to do the quaternion multiplication, so ${\bf p}{\bf q} = (p,\vec p)(q,\vec q) = (pq-\vec p\cdot\vec q,p\vec q + q \vec p + (\vec p\times\vec q))$.
If we were just to slap ${\bf p}$ and ${\bf a}$ together, we'd get ${\bf p}{\bf a} = (-s\vec p\cdot\vec a,c\vec a + s(\vec p\times\vec a))$, which isn't what we want. We want something else that's also pure imaginary (we want it to look the same as $\bf a$, after all). The usual trick to preserve properties with matrices is to multiply on the other side by a "conjugate," so we'll do this to preserve the "vectorness" and get $\bf p\bf a\bf p^*$. $\bf p^*$ will just be $(c,-\vec ps)$. Basically like a complex conjugate.
We'll end up with
$$\begin{align*} {\bf p}{\bf a}{\bf p^*} &= (-s\vec p\cdot\vec a,c\vec a + s(\vec p\times\vec a))(c,-\vec ps) \\&= (-sc\vec p\cdot\vec a,c^2\vec a + sc(\vec p\times\vec a)) + (0,s^2(\vec p\cdot\vec a)\vec p) \\&\quad- (-sc\vec a\cdot\vec p, sc(\vec a\times\vec p)) - (-s^2(\vec p\times\vec a)\cdot\vec p, s^2(\vec p\times\vec a)\times\vec p) \\&= (0,c^2\vec a + 2sc(\vec p\times\vec a)) + (0,s^2(\vec p\cdot\vec a)\vec p) + (0, s^2\vec p(\vec p\cdot \vec a)-s^2\vec a) \\&= (0,(\cos\theta)\vec a + (\sin\theta)(\vec p\times\vec a)+(1-\cos\theta)\vec p(\vec p\cdot\vec a)) \end{align*}$$
This is a lot more like you'd expect. It's pure imaginary, and everything reduces down in terms of $\theta$ instead of $\theta/2$. It also looks a lot closer in terms of how you'd write the rotation of $\vec a$ about $\vec p$.