TITLE: How do basis functions work?
QUESTION [7 upvotes]: Hopefully this isn't too broad of a question.
I recently had it explained to me that the discrete Fourier transform was really a change in basis (thus the "dot product" like look of the sigma with the multiply in it), using the sine and cosine functions as the basis functions.
I understand using dot product against new basis vectors to change points from one space to another, but I have no idea how this would work for a basis which was a function instead of a constant.
Can anyone explain the intuition for how that works?  I also have been unable to find the correct terms to search for online so am a bit lost there.
Thanks!

REPLY [6 votes]: for a basis which was a function instead of a constant

See, there is not really a dichotomy between functions and constants. A function is simply a constant of a different type than a number or a tuple. What's not constant are function values, i.e. the results of evaluating a function for some argument. Unfortunately, the notation many people use completely obscures this distinction. To make it clear: let $f : \mathbb{R} \to \mathbb{R}$ a function. Then

$f(x)$ is not a function. It is just an expression that depends on the free variable $x$. Thus it is not constant, and indeed does not make sense to consider as an element of a vector space. Lots of people will tell you that $f(x)$ is a function. They're wrong.
The function is just $f$, when not applied to any argument. If you have a proper definition like
$$
   \forall x .\ f(x) = \frac1{1+x^2}
 $$
(note that the universal quantor $\forall$ – which is usually not written out but assumed implicitly – makes $x$ is a bound variable) then $f$ as a whole is a perfectly good function-constant, just like $5$ or $\sqrt{2}$ or $b$ are perfectly good number-constants (if you previously defined it as $b = 17$).

As a matter of fact, you might consider vectors $v\in\mathbb{R}^3$ also as functions:
$$
  v : \{0,1,2\} \to \mathbb{R}
$$
or, less precisely,
$$
  v : \mathbb{N} \to \mathbb{R}.
$$
This means, $v(i)$ (or, as it's more commonly written, $v_i$) is a number, whereas $v$ as a whole is a vector.
Now, with such finite-dimensional vectors a scalar product will generally be a simple sum.
$$
  \langle v,w\rangle_{_{\mathbb{R}^3}} = \sum_{i=0}^2 v_i\cdot w_i
$$
Such a definition is equally possible if the vectors aren't functions of a natural number but a real one; for instance, you might define
$$
  \langle f,g\rangle_{_\text{Bogus}}
     = \sum_{x\in \{1,3,\pi^2\}} f(x) \cdot g(x)
$$
Only, that's not a scalar product: it's not positive definite, for instance if $f(x)$ has nozero values only for negative $x$ then $\langle f,f\rangle_{_\text{Bogus}} = 0$ even though $f\neq 0$.
Actually useful scalar products avoid this† by evaluating the functions everywhere on their domain. This is not really feasible with sums, but you can do it with integrals, like in the classical $L^2$ Hilbert space:
$$
  \langle f,g\rangle_{_{L^2(\mathbb{R})}}
     = \int_{\mathbb{R}}\!\mathrm{d}x \ f(x) \cdot g(x).
$$

†You may object that this is still not positive definite: if you plug in a function that's zero almost everywhere but e.g. $f(0)=1$, then the $L^2$ norm yields $0$ although $f\neq0$. The elements of the $L^2$ Hilbert space are in fact not general square-integrable functions, but equivalence sets of such functions modulo differences on null sets; hence we can say $f=0$ if only it's zero almost everywhere. (Alternatively, you can just say: the $L^2$ norm is a norm for all continuous functions.)