# How to calculate the distance from $X^2$ to $\operatorname{span}(1,X)$?

Question:

Let $$E = \Bbb{R}_2[X]$$ an euclidian space with a dot product $$\left\langle P,Q\right\rangle \ = \int^1_0 {P(t)Q(t)dt}$$.

Calculate the distance from $$X^2$$ to $$\operatorname{span}(1,X)$$.

Let $$(a,b) \in \Bbb{R}^2$$. $$p$$ is the orthogonal projector. We have:

$$$$a + bX = p^\perp_{\operatorname{span}(1,X)}(X^2) \iff \left\{\begin{array}{@{}l@{}} \langle X^2 - (a+bX), 1\rangle = 0\\ \langle X^2 - (a+bX), X\rangle = 0\\ \end{array}\right.\, \iff \left\{\begin{array}{@{}l@{}} a = -1/6\\ b = 1\\ \end{array}\right.\,.$$$$

So the wanted distance is $$\left\|X^2-(X-1/6)\right\| = \frac{1}{6\sqrt 5}$$.

I am a little bit lost since I don't understand how $$X^2$$ can be projected on $$\operatorname{span}(1, X)$$.

Since $$X^2$$ is not a linear combination of $$\operatorname{span}(1, X)$$.

• Why $$a + bX$$ is not equal to zero?

• How the dot products $$\langle X^2 - (a+bX), 1\rangle \ = 0$$ and $$\langle X^2 - (a+bX), X\rangle \ = 0$$ helps to get the projector? It means that we need to gets $$a$$ and $$b$$ where $$\left[X^2 - (a+bX)\right] \perp 1$$, why?

I would like to have great explanations (like if I didn't have the answer).

Think about $$\mathbb R^3$$ for a moment. Suppose you have a plane $$P$$ spanned by two vectors $$u, v$$ and you have a third vector $$w$$ which is not in the plane but is also not orthogonal to the plane. Then it makes sense to project $$w$$ onto the plane, right? But $$w$$ is not a linear combination of $$u$$ and $$v$$ because $$w$$ is not contained in the plane. It's the same idea here: as long as $$X^2$$ is not orthogonal to $$\mathrm{span}\{1, X\}$$ then $$X^2$$ has a non-zero projection onto that plane.

Now what does "orthogonal projection" mean? It means precisely the point $$s = p^\perp_P(w)$$ contained in $$P = \mathrm{span}\{u,v\}$$ such that the line from $$s$$ to $$w$$ is orthogonal to $$P$$. "The line from $$s$$ to $$w$$" is parallel to the vector $$w - s$$, so that means $$\langle w-s, u\rangle = 0\quad \langle w-s, v\rangle = 0 \tag{*}$$ because $$u,v \in P$$.

Now apply this when $$u = 1$$, $$v = X$$, and $$w = X^2$$. What the answer does is write $$s = a + bX$$ for some unknown scalars $$a, b$$; we can do this because $$s \in P = \mathrm{span}\{1, X\}$$. Then the equations ($$*$$) above give us two linear equations for the unknowns $$a, b$$ which we can then solve. This gives us the orthogonal projection $$s = p^\perp_P(X^2)$$, and finally the distance between $$X^2$$ and $$P$$ is defined to be the distance between $$X^2$$ and $$s$$, which is $$||X^2 - s||$$.

• Good job (+1). I was about to start typing something along these lines. Thanks for saving me the trouble :) Commented Feb 23 at 16:43
• Thank you very much for the explanations and the drawing by @Stéphane Jaouen, I understand better, I will study your answer and try to understand perfectly.
– Leau
Commented Feb 23 at 16:58
• I can show you a calculation or two if you want, it's up to you to finish the exercise. Commented Feb 23 at 17:04
• I would appreciate @StéphaneJaouen :)
– Leau
Commented Feb 23 at 17:09

Not much to add to @Nicolas Todoroff. Maybe a drawing that will save OP from possible difficulties with his imagination... :)

As the answers have already been given, the following calculations are to help OP complete his exercise:

As @Nicolas explained, we need to have $$X^2-(bX+a)$$ orthogonal to $$\color{grey}{span(}\color{red}1,\color{green}X\color{grey})$$, ie $$\langle X^2-bX-a,\color{red}1\rangle=0$$ for example. This is equal to $$\int_{0}^{1}(t^2-bt-a)\color{red}1dt=\frac{1}{3}-\frac b2-a=0$$ Hence $$3b+6a=2$$

Then $$\langle X^2-bX-a,\color{green}X\rangle=0 \iff 6a+4b=3$$ Thus, $$\begin{cases} 6a+3b=2\\6a+4b=3 \end{cases} \iff \begin{cases} a=\frac{-1}6\\b=1 \end{cases}$$