# How to derive formula for calculating weights in linear combinations?

Weights in the linear combination:

If $$\{u_{1}, u_{2}, ... , u_{p}\}$$ be an orthogonal basis for a subspace $$W$$ of $$R^{n}$$ , then for each $$y$$ in $$W$$, the weights for the linear combination $$y = c_{1}.u_{1} + ⋯ + c_{p}.u_{p}$$ can be defined as $$c_{j} = \frac{y.u_{j}}{u_{j}.u_{j}} \qquad j=1,2, ... ,p$$

I understood the geometrical interpretation of the above formula, but I want to know how to derive the above equation.

• You can derive that formula using “Fourier’s trick” : starting from the formula for $y$, take the dot product of both sides with $u_j$, and observe the wonderful simplification that occurs. Jun 3, 2022 at 4:39
• That was quite simple, @littleO . Thank you! Jun 3, 2022 at 4:47

Since $$y\in W$$ and $$\{u_{1}, u_{2}, ... , u_{p}\}$$ form a basis for $$W$$, it is possible to write $$y$$ as a linear combination of $$u_{1}, u_{2}, ... , u_{p}$$: $$y = c_{1}u_{1} + ⋯ + c_{p}u_{p} = \sum_{i=1}^{p}c_{i}u_{p}$$ Take dot product on both sides with respect to $$u_j$$: \begin{align} y\cdot u_j &= \left[ \sum_{i=1}^{p}c_{i}u_{p}\right] \cdot u_{j}\\ &= \sum_{i=1}^{p}c_{i}u_{i}\cdot u_{j} \end{align} Since $$\{u_{1}, u_{2}, ... , u_{p}\}$$ are also orthogonal, $$u_{i}\cdot u_{j} = 0$$ when $$i\neq j$$ and $$y\cdot u_j = c_{j}u_{j}\cdot u_{j}\\ \Rightarrow c_{j} = \dfrac{y\cdot u_j}{u_{j}\cdot u_{j}}$$