Scalar product of vectors over polynomial rings I have been studying about homomorphic encryption (HE) lately, and I am trying to perform simple computations over encrypted data. Specifically, I am interested in the scalar product between two vectors.
I came across this presentation about HElib (an implementation of HE) and on slide 32 there's this particular way of encoding vectors that gives use the scalar product after we multiply the polynomials that represent them:

Given $v=[1, 2, 3]$, $u=[4,5,6]$
If we make two polynomials such as $V(x) = 1 + 2x + 3x^2$, $U(x)=4 + 5x + 6x^2$
But $V(x)U(x) = 4 + 13x + 28x^2 + 27x^3 + 18x^4$
Change a little bit $Û(x) = 6 + 5x + 4x^2$
$V(x)Û(x) = 6 + 17x + 32x^2 + 23x^3 + 12x^4$
$32 = \langle v, u \rangle$

So my question is: How to choose the polynomial encoding of the vectors in order to obtain the scalar product value from a particular coefficient after multiplication? In other words, why inverting the representation of $U(x)$ to $Û(x)$ gave us the scalar product in the third coefficient?
To encode vectors following that technique, you just have to generalize it.

For any two $(d+1)$-dimensional vectors $a = (a_0, a_1, ..., a_d)$ and $b = (b_0, b_1, ..., b_d)$, define the polynomials $a(x) = a_0 + a_1x + ... + a_dx^d$ and $b(x) = b_d + b_{d-1}x + b_{d-2}x^2 + ... + b_0x^d$. 

Then, when multiplying $a(x)$ by $b(x)$, among all the coefficients that we multiply, we will multiply $a_0$ by $b_0x^d$, also $a_1x$ by $b_1x^{d-1}$, $a_2x^2$ by $b_2x^{d-2}$, and so on... Notice that all that multiplications are of the form $a_kx^k \cdot b_kx^{d-k}$, which result in $a_kb_kx^d$. Therefore, if we look to the $d$-th coefficient of the product polynomial we will see 

$$\left( \sum_{k=0}^d a_kb_k \right) x^d$$

and that summation is exactly the inner product between the vectors $a$ and $b$.

It is worth noting that if this summation is greater than the module of the plaintext ring (usually a parameter $t$ or $p$), than the decoding will not work. Also, that representation is only possible if that value $d$ is smaller than the degree of the polynomial used to define the quotient ring (usually a cyclotomic polynomial).