# basis for the space of polynomials $p(x)$ of degree at most $n$ such that $p(2)=p(4)=2p(7)$.

The problem: find the dimension and some basis for the space of polynomials $p(x)$ of degree at most $n$ such that $p(2)=p(4)=2p(7)$.

It is easy to see that any polynomial $p(x)$ of degree $n$ such that $p(2)=p(4)=p(7)$ can be expressed in the form $p(x) = (x-2)(x-4)(x-7)r(x) + a$, where $a$ is some scalar and $r(x)$ is a polynomial of degree $n-3$. In this case the answer is not hard: we have an isomorphism to the product of $\mathbb{C}$ and the space of polynomials of degree at most $n-3$. But this trick does not work with factor $2$ which appears in the problem.

-

A suitable generalization of the trick you described works. As you did, suppose that $p(2)=a$. Then $p(4)=a$ and $p(7)=a/2$. Consider the polynomial $$r(x)=\frac{a}{10}(x-4)(x-7)-\frac{a}{10}(x-2)(x-7)+\frac{a}{30}(x-2)(x-4).$$ This has the desired behaviour at $2$, $4$, and $7$.
If $p(x)$ is any polynomial that has values $a$, $a$, $a/2$ at our three points, then $p(x)-r(x)$ is divisible by $(x-2)(x-4)(x-7)$, and conversely.
Remark: A similar "Lagrange Interpolation" trick works more generally. The expression for $r(x)$ was not obtained by "luck." For the coefficient $c$ of $(x-4)(x-7)$, we wanted $c(2-4)(2-7)=a$, giving $c=a/10$.