%I #12 Sep 02 2018 13:35:21
%S 0,1,1,0,-1,-1,-1,0,1,3,4,4,3,2,2,2,3,4,3,4,4,3,2,2,2,3,4,0,1,1,0,-1,
%T -1,-1,0,1,-3,-2,-2,-3,-4,-4,-4,-3,-2,-3,-2,-2,-3,-4,-4,-4,-3,-2,-3,
%U -2,-2,-3,-4,-4,-4,-3,-2,0,1,1,0,-1,-1,-1,0,1,3,4,4
%N For any n >= 0 with base-9 representation Sum_{k=0..w} d_k * 9^k, let g(n) = Sum_{k=0..w} s(d_k) * 3^k (where s(0) = 0, s(1+2*j) = i^j and s(2+2*j) = i^j * (1+i) for any j > 0, and i denotes the imaginary unit); a(n) is the real part of g(n).
%C See A318706 for the imaginary part of g.
%C See A318707 for the square of the modulus of g.
%C The following diagrams shows s(k) for k = 0..8 in the complex plane:
%C |
%C |
%C s(4) s(3) s(2)
%C |
%C ---s(5)--s(0)--s(1)---
%C |
%C s(6) s(7) s(8)
%C |
%C |
%C The function g defines a bijection from the nonnegative integers to the Gaussian integers.
%C This sequence has similarities with A316657.
%H Rémy Sigrist, <a href="/A318705/b318705.txt">Table of n, a(n) for n = 0..6560</a>
%H Rémy Sigrist, <a href="/A318705/a318705.png">Colored scatterplot of (a(n), A318706(n)) for n = 0..9^6-1</a> (where the hue is function of n)
%F a(9 * k) = 3 * a(k) for any k >= 0.
%o (PARI) a(n) = my (d=Vecrev(digits(n, 9))); real(sum(k=1, #d, if (d[k], 3^(k-1)*I^floor((d[k]-1)/2)*(1+I)^((d[k]-1)%2), 0)))
%Y Cf. A316657, A318706, A318707.
%K sign,base
%O 0,10
%A _Rémy Sigrist_, Sep 01 2018