# The Lagrange Interpolation formula – Spivak's Calculus Ch 3 Problem 7(b)

The problem: Now find a polynomial function $$f$$ of degree $$n - 1$$ such that $$f(x_i) = a_i$$, where $$a, \ldots, a_n$$ are given numbers.

I found that this question had been asked before, but I did not understand the solution.

Moving on to the actual problem: we are asked to use the formula derived in the previous problem, which is: $$f_i(x) = \prod^n_{j = 1, j \neq i}\frac{x - x_j}{x_i - x_j}.$$ This function is equal to $$0$$ for all $$x_j$$ if $$j \neq i$$, and equal to $$1$$ at $$x_i$$. Note that $$x_j$$ and $$x_i$$ come from the list of distinct numbers $$x_1, \ldots, x_n$$.

My thinking as to the solution is that we simply need to multiply $$f_i(x)$$ by $$a_i$$, giving us $$f(x) = a_i \cdot \prod^n_{j = 1, j \neq i}\frac{x - x_j}{x_i - x_j}.$$ Then when we plug in $$x_i$$ we would have $$f(x_i) = a_i \cdot \prod^n_{j = 1, j \neq i}\frac{x_i - x_j}{x_i - x_j} = a_i.$$

However, in the answer key, solution is $$f(x) = \sum^n_{i = 1} a_i \cdot \prod^n_{j = 1, j \neq i}\frac{x_i - x_j}{x_i - x_j}.$$ This seems like it must be false, as substituting in $$x_i$$ gives us $$f(x_i) = \sum^n_{i = 1} \cdot \prod^n_{j = 1, j \neq i}\frac{x_i - x_j}{x_i - x_j} = \sum^n_{i = 1} a_i.$$ It looks to me like $$\sum^n_{i = 1} a_i$$ only equals $$a_i$$ if $$n = 1$$. As a result, I'm very confused as to how this answer could be correct. Any clarification would be appreciated.

• The product is within the sum - so you have a different product for each of the terms of the sum. When you plug in $x_i$ the various products are zero except for the $i^{th}$ one and this picks out the value $a_i$ for $f(x_i)$. In your formulation $f(x_j)=0$ for $j\neq i$. – Mark Bennet May 20 at 21:58

Since $$\prod_{j=1,j\neq i}^n\frac{x-x_j}{x_i-x_j}$$ maps $$x_i$$ into $$1$$ and every $$x_j$$ (with $$j\neq i$$) into $$0$$, then clearly$$\sum_{i=1}^na_i\prod_{j=1,j\neq i}^n\frac{x-x_j}{x_i-x_j}\tag1$$is what you're after. Pick some $$i\in\{1,2,\ldots,n\}$$. Then $$(1)$$ maps $$x_i$$ into$$a_1\times0+a_2\times0+\cdots+a_{i-1}\times0+a_i\times1+a_{i+1}\times0+\cdots+a_n\times0=a_i.$$