Technique to expand polynomials and equate coefficients This question concerns my attempts to re-implement parts of this paper on developing wavelet filters. Though I don't think it is necessary to look at that paper, for full context, I'm trying to compute the contents of table II (using equation 9 and the description under the heading A Spline Variant with Less Dissimilar Lengths).
To summarize the technique, we have a trigonometric polynomial in $e^{-i\xi}$ (with real coefficients) given by the product of two factors, $H\left(\xi\right)$ and $\hat{H}\left(\xi\right)$.
These factors are defined as follows:
$$
H\left(\xi\right) = 2^{-\frac{1}{2}}\left.\sum_n h_ne^{-in\xi}\right.\qquad \hat{H}\left(\xi\right) = 2^{-\frac{1}{2}}\left.\sum_n \hat{h}_ne^{-in\xi}\right.
$$
in which the coefficients are symmetric about $n=0$, that is $h_n = h_{-n}$ and $\hat{h}_n = \hat{h}_{-n}$.
We wish to derive those factors so they have as close a number of non-zero coefficients as possible (which I know to be 9 and 7 for $h_n$ and $\hat{h}_n$ respectively for the case described below).
The polynomial we have is of a simple symmetric form (derived from equation 9 in the above reference) and is as follows (I might well have made a mistake in the preceding algebra, but I'm sure the form is correct):
Defining $B = e^{-i\xi}$
$$
H\left(\xi\right)\hat{H}\left(\xi\right) = \frac{B^{-7}}{2^8}\left[-\frac{5}{16}\left(B^{14} + 1\right) + \frac{49}{16}\left(B^{12} + B^{2}\right) - \frac{245}{16}\left(B^{10} + B^{4}\right) + \frac{1225}{16}\left(B^{8} + B^{6}\right) + 128B^{7}\right]
$$
Given this, I can define $H\left(\xi\right)$ and $\hat{H}\left(\xi\right)$ as follows:
$$
H\left(\xi\right) = B^{-4}2^{-\frac{1}{2}}\left[h_0B^4 + \sum_{n=1}^{4} h_n\left(B^{4+n} + B^{4-n}\right)\right]\\
\hat{H}\left(\xi\right) = B^{-3}2^{-\frac{1}{2}}\left[\hat{h}_0B^3 + \sum_{n=1}^{3} \hat{h}_n\left(B^{3+n} + B^{3-n}\right)\right]
$$
in which I wish to find $h_n$ and $\hat{h}_n$.
Now, I can always multiply and expand out the above and attempt to equate the coefficients by hand, but this seems long, tedious and error prone.
Is there some technique I can use to automate this task? I initially thought a matrix technique, but it's not obvious to me how. It might be really trivial, so feel free to point it out as such!
Edit: I'm pretty sure I need an additional constraint to solve this uniquely. In this case it's:
$$
\sum_n (-1)^n h_n = 0 \\
\sum_n (-1)^n \hat{h}_n = 0 \\
$$
My apologies, I've only just come to this conclusion.
 A: It's not a full solution, but with a helpful pointer from a good friend, the following seems to be part way there...
It's easier to see the symmetry when the equations are written in the following form:
$$
H\left(\xi\right)\hat{H}\left(\xi\right) = \frac{1}{2^8}\left[-\frac{5}{16}\left(B^{7} + B{-7}\right) + \frac{49}{16}\left(B^{5} + B^{-5}\right) - \frac{245}{16}\left(B^{3} + B^{-3}\right) + \frac{1225}{16}\left(B^{1} + B^{-1}\right) + 128\right]
$$
and
$$
H\left(\xi\right) = 2^{-\frac{1}{2}}\left[h_0 + \sum_{n=1}^{4} h_n\left(B^{n} + B^{-n}\right)\right]\\
\hat{H}\left(\xi\right) = 2^{-\frac{1}{2}}\left[\hat{h}_0 + \sum_{m=1}^{3} \hat{h}_m\left(B^{m} + B^{-m}\right)\right]
$$
If we define
$$
c\left(p\right) = B^{p} - B^{-p}
$$
we can see that
$$
c\left(p\right)c\left(q\right) = c\left(p + q\right) + c\left(p - q\right)
$$
We can now write the product of $H\left(\xi\right)$ and $\hat{H}\left(\xi\right)$ neatly as
$$
H\left(\xi\right)\hat{H}\left(\xi\right) = \frac{1}{2}\left[h_0 + \left.\sum_{n=1}^{4}h_nc\left(n\right)\right.\right]\left[\hat{h}_0 + \left.\sum_{m=1}^{3}\hat{h}_mc\left(m\right)\right.\right]
$$
and expand that into a neat sum of products of $h_n$ and $\hat{h}_m$:
$$
H\left(\xi\right)\hat{H}\left(\xi\right) = \frac{1}{2}\left[h_0\left.\sum_{m=1}^{3}\hat{h}_mc\left(m\right)\right. + \hat{h}_0\left.\sum_{n=1}^{4}h_nc\left(n\right)\right. + \left.\sum_{n=1}^{4}\left.\sum_{m=1}^{3}h_n\hat{h}_m\left(c\left(n + m\right) + c\left(n - m\right)\right)\right.\right. + h_0\hat{h}_0\right]
$$
So, we're now in a position to see how the coefficients combine (remembering that $c\left(0\right) = 2$), equating them to the known coefficients of $H\left(\xi\right)\hat{H}\left(\xi\right)$:
\begin{align}
2\hat{h}_{1}h_{1} + 2\hat{h}_{2}h_{2} + 2\hat{h}_{3}h_{3} + \hat{h}_0h_0 &= 0.5\\
h_0\hat{h}_1 + \hat{h}_0h_1 + \hat{h}_{1}h_{2} + \hat{h}_{2}h_{1} + \hat{h}_{2}h_{3} + \hat{h}_{3}h_{2} + \hat{h}_{3}h_{4} &= \frac{1225}{2^{12}}\\
h_0\hat{h}_2 + \hat{h}_0h_2 + \hat{h}_{1}h_{1} + \hat{h}_{1}h_{3} + \hat{h}_{2}h_{4} + \hat{h}_{3}h_{1} &= 0\\
h_0\hat{h}_3 + \hat{h}_0h_3 + \hat{h}_{1}h_{2} + \hat{h}_{1}h_{4} + \hat{h}_{2}h_{1} &= \frac{-245}{2^{12}}\\
\hat{h}_0h_4 + \hat{h}_{1}h_{3} + \hat{h}_{2}h_{2} + \hat{h}_{3}h_{1} &= 0\\
\hat{h}_{1}h_{4} + \hat{h}_{2}h_{3} + \hat{h}_{3}h_{2} &= \frac{49}{2^{12}}\\
\hat{h}_{2}h_{4} + \hat{h}_{3}h_{3} &= 0\\
\hat{h}_{3}h_{4} &= \frac{-5}{2^{12}}
\end{align}
I think with the additional constraints:
$$
\sum_n (-1)^n h_n = 0 \\
\sum_n (-1)^n \hat{h}_n = 0 \\
$$
that should be solvable...
