# Determine the coordinates of a polynomial with respect to a basis

Let $$a_0,a_1,...,a_n\in\mathbb{R}$$ distinct numbers and the polynomials:

$$P_k(x)=\frac{(x-a_0)(x-a_1)...(x-a_{k-1})(x-a_{k+1})..(x-a_n)}{(a_k-a_0)...(a_k-a_{k-1})(a_k-a_{k+1})...(a_k-a_n)}$$

$$k$$ from $$0$$ to $$n$$.

find coordinates of an arbitrary polynomial $$Q\in\mathbb{R}_{\leq n}[X]$$ with respect to that basis formed by those polynomials.

Let $$b_0,b_1,...,b_n\in\mathbb{R}$$ not necessarily distinct. show that there exists a unique polynomial of degree $$n$$ such that $$P(a_k)=b_k\forall k=0$$ to $$k=n$$

Which is $$P(X)=b_0P_0(X)+...+b_nP_n(X).$$

My attempt for the first one:

We can observe that $$P_k(a_j)=1$$ iff $$k=j$$ and $$P_k(a_j)=0$$ otherwise. If we try to associate a vector in $$\mathbb{R}^n$$ for every polynomial $$P_k$$ and form a matrix with all polynomial from $$k=1$$ to $$k=n$$, we can see that we get a matrix with $$a_{i,i}=1\implies$$ it's determinant its $$\neq0.$$ so the vectors are linear independent $$\implies$$ the polynomials form a basis.

Now to determine the coordinates I thought to take $$Q(x)= q_0+q_1x+...+q_nx^n=\lambda_0P_0+...+\lambda_nP_n$$ but that's pretty hard to compute isn't there an easier way?

Take a polynomial $$Q$$ of degree at most $$n$$, and suppose there exist scalars $$\lambda_0, \ldots, \lambda_n$$ such that $$Q = \lambda_0 P_0 + \cdots + \lambda_n P_n$$. Then it is easy to tell what these scalars are, since $$Q(a_k) = \lambda_0 P_0(a_k) + \cdots + \lambda_n P_n(a_k) = \lambda_k P_k(a_k) = \lambda_k$$ and hence we must have that $$\lambda_0 = Q(a_0), \ldots, \lambda_n = Q(a_n)$$.
The above argument applied to $$Q = 0$$ shows that the $$P_0, \ldots, P_n$$ are linearly independent, and hence they are spanning since we know that $$\dim \mathbb{R}_{\leq n}[x] = n + 1$$.