# \ #
# \mbox{This can be done -- and both simultaneously -- } \mbox{using complex exponentials. (I will take |r| < 1.)} #
# \mbox{We proceed:} #
# \qquad \qquad sum_{n=0}^{\infty} r^n cos(n x) \ + \ i sum_{n=0}^{\infty} r^n sin(n x) \ = #
# \qquad \qquad \qquad \qquad sum_{n=0}^{\infty} r^n ( cos(n x) \ + \ i sin(n x) ) \ = #
# \qquad \qquad \qquad \qquad sum_{n=0}^{\infty} r^n e^{ i n x } \ = sum_{n=0}^{\infty} ( r e^{ i x } )^n \ = #
# \qquad \qquad 1 /{ 1 \ - \ r e^{ i x } }; \qquad \mbox{infinite geometric series with:} #
# \qquad \qquad \qquad \qquad \qquad \qquad \qquad \qquad \mbox{first term} \ = \ 1; #
# \qquad \qquad \qquad \qquad \qquad \qquad \qquad \qquad \mbox{common ratio} = r e^{ i x }, #
# \mbox{noting:} \ | r e^{ i x } | = | r | \cdot | e^{ i x } | = | r | \cdot 1 = | r | < 1, #
# \qquad \qquad \qquad \qquad \qquad \qquad \qquad \qquad \qquad \qquad \mbox{the last inequality valid by assumption made here}. #
# \mbox{Thus:} #
# \qquad \qquad sum_{n=0}^{\infty} r^n cos(n x) \ + \ i sum_{n=0}^{\infty} r^n sin(n x) \ = 1 /{ 1 \ - \ r e^{ i x } }. \qquad (1) #
# \mbox{Writing the latter in standard complex form:} #
# \qquad \qquad 1 / { 1 \ - \ r e^{ i x } } \ = \ 1 / { 1 \ - \ r e^{ i x } } \cdot ( { 1 \ - \ r e^{ -i x } } / { 1 \ - \ r e^{- i x } } ) #
# \qquad \qquad = \ { 1 \ - \ r e^{ -i x } } / { 1 \ - \ r ( e^{ i x } + e^{ -i x } ) \ + \ r^2 } #
# \qquad \qquad = \ { 1 \ - \ r [ cos(-x) + i sin(-x) ] } / { 1 \ - \ r ( e^{ i x } + e^{ -i x } ) \ + \ r^2 } #
# \qquad \qquad = \ { 1 \ - \ r [ cos(x) - i sin(x) ] } / { 1 \ - \ r ( 2 cos(x) ) \ + \ r^2 } #
# \qquad \qquad = \ { 1 \ - \ r cos(x) + i r sin(x) } /
{ 1 \ - \ 2r cos(x) \ + \ r^2 } #
# \qquad = \ ( { 1 \ - \ r cos(x) } /
{ 1 \ - \ 2r cos(x) \ + \ r^2 } ) \ + \ i ( { r sin(x) } /
{ 1 \ - \ 2r cos(x) \ + \ r^2 } ). #
# \mbox{Thus:} #
# 1 / { 1 \ - \ r e^{ i x } } = #
# \qquad \qquad ( { 1 \ - \ r cos(x) } /
{ 1 \ - \ 2r cos(x) \ + \ r^2 } ) \ + \ i ( { r sin(x) } /
{ 1 \ - \ 2r cos(x) \ + \ r^2 } ). #
# \mbox{Combining (1) with the previous, we have:} #
# \qquad \qquad sum_{n=0}^{\infty} r^n cos(n x) \ + \ sum_{n=0}^{\infty} i r^n sin(n x) \ = #
# \qquad \qquad \qquad ( { 1 \ - \ r cos(x) } /
{ 1 \ - \ 2r cos(x) \ + \ r^2 } ) \ + \ i ( { r sin(x) } /
{ 1 \ - \ 2r cos(x) \ + \ r^2 } ). #
# \mbox{Equating real and imaginary parts gives the result:} #
# \qquad \qquad sum_{n=0}^{\infty} r^n cos(n x) \ = \ { 1 \ - \ r cos(x) } / { 1 \ - \ 2r cos(x) \ + \ r^2 }; #
# \qquad \qquad sum_{n=0}^{\infty} r^n sin(n x) \ = \ { 1 \ - \ r sin(x) } / { 1 \ - \ 2r cos(x) \ + \ r^2 }. \qquad \qquad \qquad \qquad \quad square #