# Looking for closed-form least squares solution of a simplified inverse kinematics problem

Given $X_i, Y_i \in SO_3, i=1..n, n>2$, find $A,B$ that satisfies $AX_iB=Y_i$.

For $n=1$, there are an infinite number of solutions, a trivial one is:
$B=I$
$A=Y_1X_1^T$

For $n=2$, there should be exactly one solution. One could do the following:
Compute $A$ from the equation where $i=1$: $A=Y_1B^{-1}X_1^{-1}$,
Substituting this into equation where $i=2$: $Y_1B^{-1}X_1^{-1}X_2B=Y_2$,
Now, let $C=X_1^{-1}X_2$ and $D=Y_1^{-1}Y_2$,
We get: $B^{-1}CB=D$,
Which can be rewritten as: $CB=BD$
I'm already lost at this point. How do I solve for $B$, given $D,C$?

And now for $n>2$, how can I find a solution that minimizes the least squares error? Is it possible to rearrange the $n$ equations into a linear system at all? Or do I need to look into using some kind of iterative approach or linear programming instead?

-

$\mathbf{C}\mathbf{B}-\mathbf{B}\mathbf{D}=\mathbf{0}$ is a Sylvester equation, for which algorithms like Bartels-Stewart or Hessenberg-Schur apply.

I haven't seen your more general problem in my notes, but I'll update this answer when I find something.

-
Thanks for the info regarding that equation, it was very helpful! It made me realize that finding the solution for the generic case is much more difficult, than I initially had thought. So I ended up using a simple iterative approach to find a solution, and that works well even for the generic case. –  Andras Oct 1 '10 at 8:58