Quote:
Originally Posted by CRGreathouse
Let me look at that formula and see if there is a good way to translate between it and my problem (essential solutions, not including sign and ordering).

Consider different cases depending on the number of nonzero squares in the expansion. If the number of nonzero squares is k, then this expansion is counted 2^k times if signs are taken into account.
Ordering is also possible to take into account by considering cases with distinct/equal squares.