# What Is The General Term Of These Sequences?

$a_{n,3}$

$$1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,\cdots \cdots$$

$a_{n,5}$

$$1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,\cdots \cdots$$

$a_{n,7}$

$$1,0,0,0,0,0,0,1,0,0,0,0,0,0,1,0,0,0,0,0,0,1,0,0,0,0,0,0,1,0,\cdots \cdots$$

$$\vdots$$

$a_{n,2k+1}$

$$1,\cdots \cdots\cdots \cdots,1,\cdots \cdots\cdots \cdots,\overbrace{1,\cdots \cdots\cdots \cdots}^{2k+1},1,\cdots \cdots\cdots \cdots,1,\cdots \cdots$$

I found $$a_{n,k}= \left \lfloor \left | \cos\frac{\pi (n-1)}{2k+1} \right | \right \rfloor$$ but this term include abs and floorfucntion.

I mean i want the General Term without abs and floorfucntion.(plus sum)

Any hints will be appreciated, thank you.

-
I am curious about why you want something other than the usual $a_{n,k}=1$ if $n \equiv 1 \pmod{2k+1}$, $a_{n,k}=0$ otherwise? Pure curiosity? A programming problem in a very linited setting? If we knew more about the reason, a more satisfying answer might be possible. – André Nicolas Jul 16 '11 at 21:59
If your computing environment is the sort of computing environment where TRUE is 1 and FALSE is 0 (C, for instance), then joriki's answer becomes even more practical... – J. M. Jul 17 '11 at 2:10

$$a_{n,j}=\delta_{1,n \,\bmod\,j}$$

-
Judging from the OP's own suggestion his indexing begins from $n=1$ as opposed $n=0$. Also, it looks like you want to look at the remainder of $n$ modulo $j$ - not the other way round. – Jyrki Lahtonen Jul 16 '11 at 10:33
Thanks, you're right on both accounts -- I edited accordingly. – joriki Jul 16 '11 at 10:44
@ks0830: We can try -- I've never done that before -- I've entered the mathematics chat room at chat.stackexchange.com/rooms/36/mathematics now. – joriki Jul 16 '11 at 10:51

$$a_{n,j}=\frac1j\sum_{k=0}^{j-1}\mathrm e^{2\pi\mathrm i(n-1)k/j}$$

If you want to avoid the summation, you can apply the formula for a geometric sum to get

$$a_{n,j}=\frac1j\frac{1-\mathrm e^{2\pi\mathrm i(n-1)}}{1-\mathrm e^{2\pi\mathrm i(n-1)/j}}\;.$$

This isn't actually defined for $n=1$, but the limit for $n\to1$ is the value you want.

-
Then I suggest you give a clear and complete definition of "closed form" in the question. – joriki Jul 16 '11 at 10:21
This is neat. In fact you could apply fourier analysis to all sorts of continuous or smooth functions extending the values given to the real numbers. And if limits are allowed there are other formulations which would work as 'closed formulae' but which would probably not be useful computationally. – Mark Bennet Jul 16 '11 at 20:02

The following is a technically correct answer to the question, though that depends on what kind of technician you are. The answer is quite close to the OP's proposal. Let
$$f(n,k)=\sin^2\left(\frac{\pi(n-1)}{2k+1}\right).$$

Let $$g(n,k)=0^{f(n,k)}.$$

Then, with a few largish caveats, $g(n,k)$ does the job.

Explanation: The issue, of course, is what do we mean by $0^0$? In calculus courses it is best to consider $0^0$ to be undefined. That is, however, not a universal convention.

For example, according to the IEEE floating point standard 754-2008 for the operation pow, $0^0=1$, and $0$ to a positive power is $0$. A Wikipedia article (what else?) tells me that many computer languages implement this standard. A few desultory tests with the Google calculating utility seem to show that it also implements the standard.

Added: The procedure will break down for very large $k$, because of implementation details of the IEEE standard. We can delay the breakdown by using a function that goes to $0$ more slowly than $\sin^2$ near integer multiples of $\pi$. But since presumably the question is not motivated by practical considerations, I will not suggest such modifications.

-
Therfore, as always, what $0^0$ "is" completely depends on the environment... :) – J. M. Jul 17 '11 at 1:52
@J.M.: Absolutely. There is no way otherwise to produce that kind of discontinuity with the narrow range of "allowed" functions. – André Nicolas Jul 17 '11 at 2:04
...which reminds me, your proposal is quite related to ones by Libri and Möbius, as recounted here (see p. 406 onwards). (added: now that I can upvote, I gave a +1 for "But since presumably the question is not motivated by practical considerations, I will not suggest such modifications." :D ) – J. M. Jul 17 '11 at 2:09
@J.M.: Thanks for the link, it is always a pleasure to read Knuth. – André Nicolas Jul 17 '11 at 2:12
@ks0830: No problem, I wrote it up for fun. In your answer involving $\cos$, you can square instead of using absolute value, thereby having only one operation you don't approve of instead of two. With the standard continuous real functions, one cannot do better than one except by using mathematically suspect quirks of computer implementation. – André Nicolas Jul 17 '11 at 5:06