# Given vector $\vec x = \left\{ x_i\right\}_{i=1}^n$ find an algebraic expression for $\vec y = \left\{ x^2_i\right\}_{i=1}^n$

Given vector $$\vec x = \begin{bmatrix} x_1 \\ \vdots \\ x_n \end{bmatrix},$$ How can we write out vector $$\vec y = \begin{bmatrix} y_1 \\ \vdots \\ y_n \end{bmatrix} := \begin{bmatrix} x^2_1 \\ \vdots \\ x^2_n \end{bmatrix}$$ in terms of $\vec x$ using only matrix operations?

It is simple to write $\vec y$ in terms of $\vec x$ element wise, for example in the form of system of equations $y_i = x_i^2$ for $i = 1, \dots, n$. However, I am struggling to do so using matrix notation and operations.

The best guess I could come up with was to write expressions like \begin{aligned} \vec y &= \vec x ^T \cdot I_{n \times n} \cdot\vec x, & I_{n \times n} -\text{ identity matrix, } & & I_{n \times n} & = \begin{bmatrix} 1 & 0 & \cdots & 0 \\ 0 & 1 & \cdots & 0 \\ \vdots & \vdots & \ddots & \vdots \\ 0 & 0 & \cdots & 1 \\ \end{bmatrix} \\ \vec y &= \left\langle \vec x, \vec x \right \rangle = \left\| \vec x \right\| & - \text{ inner product / norm, } & & \left\| \vec x \right\| &= \left\langle \vec x, \vec x \right \rangle = \sum_{i=1}^{n} x_i^2 \end{aligned} both of which are obviously flawed.

Any hint would be appreciated.

• What's wrong with using $\vec{y} = \vec{x}^T I_{n \times n} \vec{x}$? I guess I'm not sure what type of answer you're looking for if that expression doesn't do the job. – Xoque55 Aug 3 '15 at 12:40
• @Xoque55 The expression $\vec{x}^T I_{n \times n} \vec{x}$ results in a scalar, whereas I am trying to construct a vector. In fact, $\vec{x}^T I_{n \times n} \vec{x}$ is equivalent to $\vec{x}^T \cdot \vec{x}$, since the presence of identity matrix does not make any difference in this formula. – Vlad Aug 3 '15 at 12:43
• <smacks forehead> – Xoque55 Aug 5 '15 at 21:52

Note: It's not clear what "using only matrix operations" means. What motivation do you have for this computation? From a normal geometric point of view, this isn't a natural thing to do because it's basis dependent.

But assuming we're happy to choose the privileged basis $$\vec{e}_1 = (1,0,0), \quad \vec{e}_2 = (0,1,0), \quad \vec{e}_3 = (0,0,1)$$ since we have to do something to break the symmetry under changes of basis, we can write the answer as follows:

$$\vec{y} = (\vec{e}_1 \cdot \vec{x})^2 \vec{e}_1 + (\vec{e}_2 \cdot \vec{x})^2 \vec{e}_2 + (\vec{e}_3 \cdot \vec{x})^2 \vec{e}_3$$

If you prefer, you could write this as

$$\vec{y} = \left( (\vec{e}_1^\dagger \vec{x}) (\vec{e}_1 \vec{e}_1^\dagger) +(\vec{e}_2^\dagger \vec{x}) (\vec{e}_2 \vec{e}_2^\dagger) +(\vec{e}_3^\dagger \vec{x}) (\vec{e}_3 \vec{e}_3^\dagger) \right) \vec{x}$$

which evaluates to

$$\vec{y} = \left( x_1 \pmatrix{1 & & \\ & 0 & \\ & & 0} +x_2 \pmatrix{0 & & \\ & 1 & \\ & & 0} +x_3 \pmatrix{0 & & \\ & 0 & \\ & & 1} \right) \vec{x}$$

• This is exactly what I was looking for, thank you for the answer! I guess it is impossible to have similar expression for a more general case of, say, non-orthonormal basis, is it? – Vlad Aug 3 '15 at 12:47
• It's not clear what you're asking again and it's hard to guess without any context -- you could either mean writing a similar expression but in terms of some other $\vec{e}'_i$, or you could mean that you have written the 3D coordinates of $\vec{x},\vec{y}$ in some other basis in the first place -- but in any such case you can always figure out some such expression. You should always be able to form some scalar which evaluates to $x_1$, and some vector which corresponds to the first basis vector in your space, so squaring the first and multiplying by the last, you'll get there. – Sharkos Aug 3 '15 at 15:26

What you are looking for is a vector-valued bilinear form.

Let $B$ be a bilinear form from $\mathbb{R}^n \times \mathbb{R}^n$ into $\mathbb{R}^n$, such that, for all $i,j,k\in\{1,\cdots n\}$,

$B_{i,j}^k =1$ if $i=j=k$

and

$B_{i,j}^k =0$ otherwise

Then you have $\vec{y} = B(\vec{x},\vec{x})$.

In terms of coordenates: $y_k=\sum_{i,j=1}^{n}B_{i,j}^k x_i x_j=(x_k)^2$

Remark: If you want to think of $B$ as a vector of matrices, it is $$B = \left( \pmatrix{1 & & \\ & 0 & \\ & & 0}, \pmatrix{0 & & \\ & 1 & \\ & & 0}, \pmatrix{0 & & \\ & 0 & \\ & & 1} \right)$$ And the rule to apply it to vectors $\vec{v}$ and $\vec{w}$ is $$B(\vec{v},\vec{w}) = \left( \vec{v}^T \pmatrix{1 & & \\ & 0 & \\ & & 0}\vec{w}, \vec{v}^T \pmatrix{0 & & \\ & 1 & \\ & & 0}\vec{w}, \vec{v}^T\pmatrix{0 & & \\ & 0 & \\ & & 1}\vec{w} \right)$$

Note that this way to write $B$ and to write $B(\vec{v},\vec{w})$ generalizes to any bilinear form from $\mathbb{R}^n \times \mathbb{R}^n$ into $\mathbb{R}^n$.

• That seems to be a reasonable approach. Is it possible to express such a vector-valued bilinear form in terms of matrices, similar to the regular scalar-valued bilinear form? – Vlad Aug 3 '15 at 12:57
• @Vlad The expression of $B$ is already in "matrice" form. It is a $n\times n \times n$ "matrice". Of course, you can write $B$ as a vector of matrices, but, in general, we do not do that when working with vector-based bilinear forms. The kind of computation you proposed is natural when we are dealing with vector-valued bilinear forms. And it actually generalize even to infinite dimensions. – Ramiro Aug 3 '15 at 13:11
• @Vlad If you want to think of $B$ as a vector of matrices, it is $$B = \left( \pmatrix{1 & & \\ & 0 & \\ & & 0}, \pmatrix{0 & & \\ & 1 & \\ & & 0}, \pmatrix{0 & & \\ & 0 & \\ & & 1} \right)$$ – Ramiro Aug 3 '15 at 13:31
• +1 This is a nice answer with a very different interpretation of the question. $B$ is a tensor, which at this level you can think of as the natural generalization of scalars, vectors, and matrices to more indices -- or more geometrically to linear maps between spaces with more dimensions. – Sharkos Aug 3 '15 at 15:28

$\begin{pmatrix} x_1 & 0 & 0\\ 0 & x_2 & 0\\ 0 & 0 & x_3\\ \end{pmatrix}\begin{pmatrix}x_1\\x_2\\x_3\end{pmatrix}=\begin{pmatrix}x_1^2\\x_2²\\x_3^2\end{pmatrix}$

• How to express $\left( \begin{smallmatrix} x_1 & 0 & 0 \\ 0 & x_2 & 0 \\ 0 & 0 & x_3\end{smallmatrix}\right)$ in terms of $\vec x$ and matrix operations? – Vlad Aug 3 '15 at 12:31