Dimension of a vector space of functions

Where $$S$$ is a set, the functions $$f: S \rightarrow \mathbb{R}$$ form a vector space under the natural operations: the sum $$f+g$$ is the function given by $$f +g(s)=f(s)+g(s)$$ and the scalar product is $$r\cdot f(s) = r\cdot f(s)$$. What is the dimension of the space resulting for each domain?

(a) $$S = \{1\}$$ $$\hspace{1mm}$$ (b) $$S = \{1,2\}$$ $$\hspace{1mm}$$ (c) $$S = \{1,...,n\}$$

The result of my attempt at the problem is that the dimension in each case should be infinitely large. My reasoning is that the set of functions, in either (a), (b), or (c), contains the space of $$n$$ degree polynomials functions $$\mathscr{P}_n$$, as any polynomial function takes values in all mentioned domains and returns a value in $$\mathbb{R}$$. Since $$\mathscr{P}_n$$ has an infinitely large dimension, as $$n \in \mathbb{N}$$ and $$\mathbb{N}$$ (the set of natural numbers) is infinitely large, the basis of the space containing $$\mathscr{P}_n$$ is infinitely large, and so must be the bases for the spaces in question. Therefore, the spaces in question have infinitely large dimensions.

However, the solution to the problem is

(a) dimension $$=1$$

(b) dimension $$=2$$

(c) dimension $$=n$$

I see how the solutions apply to each case but my question is why? Where in my reasoning am I making a mistake? Thank you in advance.

• Distinct polynomials can have the same values on $S$ and therefore induce the same function from $S \to \mathbb R$. For example, all polynomials $p$ satisfying $p(1) = 0$ result in the same function from $\{1\} \to \mathbb R$. – Bungo Oct 9 at 17:52
• Thank you for the response Bungo. Can't you just apply the same logic and say all polynomials $p(1) =1$, $p(1)=2$, and so forth and still have an infinitely large collection of functions? – Andy Oct 9 at 18:06
• Of course. The dimension of a vector space isn't the same as its cardinality. For example, the vector space $\mathbb R^2$ has dimension 2 over $\mathbb R$ (any basis contains two vectors), but there are infinitely many vectors in the space, namely all linear combinations of the two basis vectors. – Bungo Oct 9 at 18:08
• See if you can convince yourself that the set of all functions $S = \{1,2\} \to \mathbb R$ is actually the same thing as $\mathbb R^2$. – Bungo Oct 9 at 18:13

Hint: For the general case $$S=\{1,...,n\}$$, prove that the functions $$f_1,...,f_n$$ defined as $$f_i(i)=1$$ and $$f_i(j)=0$$ for $$i\neq j$$, forms a basis.
In other words, show that $$f_1,...,f_n$$ are linearly independent and that for any function $$g:S\rightarrow \mathbb{R}$$, we can write $$g$$ as $$\alpha_1f_1 + \alpha_2f_2 + ... + \alpha_nf_n$$ for suitable $$\alpha_1,...,\alpha_n$$.
How can a polynomial belong to those spaces? If you are talking about polynomial functions, then you are making a mistake. Consider, for instance, the polynomial functions $$x^n$$ ($$n\in\mathbb N$$). They are all distinct as functions from $$\mathbb R$$ into $$\mathbb R$$. But they become all the same function if you restrict them to $$\{1\}$$!
• Thank you for the response José. I see your point, but can't you just take the polynomial functions $x^n + x^{n-1}$ and have another set of functions that are distinct on $\{1\}$? – Andy Oct 9 at 18:11
• @Andy When restricted to $S = \{1\}$, we have $x^n = x^{n-1}$ (they are the same function on the restricted domain), so $x^n + x^{n-1} = 2x^n$. In the same way, any function $\{1\} \to \mathbb R$ is a scalar multiple of $x^n$ restricted to $\{1\}$. In other words, the set consisting of the single function $x^n$ (or any other nonzero function $\{1\} \to \mathbb R$) constitutes a basis. – Bungo Oct 9 at 19:08