Fitting a polynomial of second order and a line and estimate error

54 Views Asked by At

Let $X \in \mathbb{R}^{N \times 2}$, such that \begin{equation} X = \begin{bmatrix} 1 & 0 \newline \vdots & \vdots \newline N & 0 \end{bmatrix} \end{equation} Let $Y \in \mathbb{R}^{N \times 2}$, such that \begin{equation} Y = \begin{bmatrix} 1 & f(1) \newline \vdots & \vdots \newline N & f(N) \end{bmatrix} \end{equation} where $f(i) = bi^2$. It is possible to find the best rotation matrix that fits $X$ and $Y$:

\begin{equation} min_\theta \| X-YR(\theta) \|_F^2 \end{equation}

where $R(\theta)$ is a rotation matrix, and derive an expression for the angle $\theta$. Is there a shorter way to derive to a concise expression for this angle ?

2

There are 2 best solutions below

0
On BEST ANSWER

This is basically Miss Mae's answer using vectors.

Define the column vectors and matrices

$$ u = \begin{bmatrix} 1 \\ \vdots \\ N \end{bmatrix} \! , ~ v = \begin{bmatrix} 1^2 \\ \vdots \\ N^2 \end{bmatrix} \!, ~ X = \begin{bmatrix} | & | \\ u & 0 \\ | & |\end{bmatrix} \!, ~ Y = \begin{bmatrix} | & | \\ u & v \\ | & | \end{bmatrix} \!, ~ R=\begin{bmatrix} \cos\theta & -\sin\theta \\ \sin\theta & \cos\theta \end{bmatrix} \! . $$

The columns of $YR$ are $p=\cos\theta u+\sin\theta v$ and $q=-\sin\theta u+\cos\theta v$. Therefore,

$$ \begin{array}{ll} \|X-YR\|^2 & = \|u-p\|^2+\|-q\|^2 \\ & = \|u\|^2-2u\cdot p+\|p\|^2+\|q\|^2 \\ & = \|u\|^2-2u\cdot p+\|u\|^2+\|v\|^2. \end{array}$$

(Note $\|p\|^2+\|q\|^2=\|u\|^2+\|v\|^2$ is just $\|YR\|^2=\|Y\|^2$.) Then

$$ \arg\min_\theta \bigl(2\|u^2\|+\|v\|^2-2u\cdot p\bigr)~=~\arg\max_\theta(u\cdot p). $$

We can write $u\cdot p=u\cdot (\cos\theta u+\sin\theta v)=(\cos\theta,\sin\theta)\cdot(\|u\|^2,u\cdot v)$ which is maximized when $(\cos\theta,\sin\theta)$ equals $(\|u\|^2,u\cdot v)$ normalized, so we get

$$ \tan\theta=\frac{u\cdot v}{\|u\|^2}=\left(\frac{1^3+\cdot+N^3}{1^2+\cdot+N^2}\right)b. $$

With $1^2+\cdots+N^2=N(N+1)(2n+1)/6$ and $1^3+\cdots+N^3=(n(n+1)/2)^2$:

$$ \theta = \tan^{-1} \left(\frac{3N(N+1)}{2(2N+1)}b\right). $$

Note that $\cos\theta=\|u\|^2/\sqrt{\cdots}\ge0$ means $-\frac{\pi}{2}<\theta<\frac{\pi}{2}$ is in the range of $\tan^{-1}$.

0
On

Given $X \in \mathbb{R}^{N \times 2}$ and $Y \in \mathbb{R}^{N \times 2}$, $$ X = \begin{bmatrix} 1 & 0 \newline \vdots & \vdots \newline N & 0 \end{bmatrix},\qquad Y = \begin{bmatrix} 1 & 1^2b \newline \vdots & \vdots \newline N & N^2b \end{bmatrix} $$

We can express:

$$\min_\theta \| X-YR(\theta) \|^2$$

as

$$\min_\theta \sum^N_{n=1}(n-n\cos(\theta)-n^2b\sin(\theta))^2 + (n\sin(\theta)+n^2b\cos(\theta))^2,$$

$$\min_\theta \sum^N_{n=1}n^2-2n(n\cos(\theta)+n^2b\sin(\theta))+(n^2+n^4b^2),$$

$$\min_\theta \sum^N_{n=1} 2n^2 + n^4b^2 - 2b\sin(\theta)\sum^N_{n=1}n^3 - 2\cos(\theta)\sum^N_{n=1}n^2$$

Let $P_s = \sum^N_{n=1}n^s$, then,

$$\min_\theta 2P_2 + b^2P_4 - 2b\sin(\theta)P_3 -2\cos(\theta)P_2$$

Since $2P_2 + b^2P_4$ are constants, we are then looking to minimize $2b\sin(\theta)P_3 -2\cos(\theta)P_2$ from the above. Thus, we really just need to find a solution to:

$$\min_\theta -b\sin(\theta)P_3 -\cos(\theta)P_2$$

Which is:

$$-\frac{N^2(N+1)^2b\sin(\theta)}{4} - \frac{N(N+1)(2N+1)\cos(\theta)}{6}$$

Thus the minimum of the objective function is:

$$2\sum^N_{n=1}n^2 + b^2\sum^N_{n=1}n^4 - \max_\theta \left\{\frac{N^2(N+1)^2b\sin(\theta)}{4} + \frac{N(N+1)(2N+1)\cos(\theta)}{6}\right\}$$