Decomposing rotation into rotation around certain axis and remaining rotation Let R be a rotation matrix in three-dimensional euclidean space, R ∈ SO(3).
Let v be a unit vector in said space. 
Is it possible to decompose R into matrices A and B so that following holds?  


*

*AB = R 

*A is a rotation around the axis indicated by v


If it is possible, how can it be done? 
 A: You can solve for $B$ as follows.  Let $R$ be the rotation you specified, and $A$ be any rotation around the axis indicated by $v$.  Then define
      $$B = A^{-1}R$$
$A$ has an inverse since all rotations do.  Now
$$AB = R$$
A: You already seen that $B = A^{-1} R$, but what is $A$? 
Use the rotation $\varphi$ about an axis $\bf v$ formula defined as
$$ A = \mathbf{1}+(\sin\varphi) [\mathbf{v}\times] + (1-\cos\varphi) [\mathbf{v}\times][\mathbf{v}\times]$$
where $[\mathbf{v}\times]$ is the 3×3 skew symmetric cross product operator. It follows that
$$ A^{-1} = \mathbf{1}-(\sin\varphi) [\mathbf{v}\times] + (1-\cos\varphi) [\mathbf{v}\times][\mathbf{v}\times]$$
So now we have an expression for $B$ in terms of the angle $\varphi$
$$ B(\varphi) = R -(\sin\varphi) \mathbf{v}\times R + (1-\cos\varphi) \mathbf{v}\times \mathbf{v}\times R $$
To find $\varphi$ I suggest taking the trace if $B$ and maximizing it. Why? The trace of any 3×3 rotation matrix is: ${\rm trace}(R(\theta))=(1+2\cos\theta)$ with a maximum value at $\theta=0$. By maximizing the trace we are finding rotation $\varphi$ which yields the smallest rotation $B$.
NOTE:
The trace of a combined rotation is 
$${\rm trace}( {\rm Rot}(\mathbf{u},\varphi){\rm Rot}(\mathbf{v},\theta)) =\\ n^2+\cos\theta (1-n^2)+\cos\varphi(1-n^2+\cos\theta(1+n^2))-2(\sin\varphi\sin\theta) n$$
where $n=\mathbf{v}\cdot\mathbf{u}$ is the dot product of the two axes.
A: As the other answers note, $B = A^{-1}R$, or equivalently $BR^{-1} = A^{-1}$.
If you would like the Axis/Angle representations of $A$ and $B$ to be orthogonal (i.e. so that $AA(A) \cdot AA(B) = 0$), it is possible to do this explicitly without solving an optimization problem.
First, if $AA(A) || v$, then choose some vector $w$ s.t. $w \cdot v = 0$.  
Now we want to find the matrix $B$ s.t. $BR^{-1} w \cdot v = 0$.  
To do this, we first compute a (normalized) projection $p = \frac{R^{-1}w - (R^{-1}w \cdot v)v}{||R^{-1}w - (R^{-1}w \cdot v)v||}$ (Formula to project a vector onto a plane).
Now we compute $B$ to be the matrix that rotates $R^{-1}w \rightarrow p$ (Calculate Rotation Matrix to align Vector A to Vector B in 3d?).
The resulting matrix ($BR^{-1} || RB^{-1} = A$) fixes the axis $v$ by construction, and $B$ must fix an axis orthogonal to $v$.
