Haven't tried it completely but you might be able to work out a recursive formula, if that should help you

something like

D(n) = [+1or-1].x.D(n-1) + [+1or-1].[a^2(or)b^2].D(n-2)

values within square brackets will depend on 'n', in case of n=6

D(6) = x.D(5) + a^2.D(4)