# is $\frac{\{1, \ldots ,n\}}{n+1}$ proper notation when $n\geq1$?

I am trying to explain R code:

(1:n)/(n+1)


such that:

> n <- 4
> (1:n)/(n+1)
[1] 0.2 0.4 0.6 0.8


I might use

$$\frac{\{1, \ldots ,n\}}{n+1}$$

Is that okay? It seems to imply $n\neq1$. Does it?

-
What is the notation supposed to mean? – Chris Eagle Jun 7 '12 at 0:06
The notation $\{1,\ldots,n\}$ usually means the empty set when $n=0$. That's common practice in mathematics, but I don't know how well that translates to programming languages. – Egbert Jun 7 '12 at 0:10
@Egbert Most programming languages do the same thing because otherwise you get really unexpected results. If you try to index some sequence value with a[1 .. length(a)] you get a bizarre answer for sequences of length 0 or 1 unless the definition of .. follows the mathematical conventions. – MJD Jun 7 '12 at 0:21
@MarkDominus That sounds reasonable :) – Egbert Jun 7 '12 at 0:25
@Egbert: Even in the not-particularly-mathematically-oriented C programming language, the usual idiom of iterating over the sequence $1,\ldots,n$ via for (int i = 1; i <= n; i++) performs exactly $n$ iterations even when $n$ is $0$ or $1$. I'd say $\{1,\ldots,n\}=\emptyset$ is a law of nature. :) – Rahul Jun 7 '12 at 0:42

A lot of people are going to be completely mystified if you write $$\frac{\{1, ... ,n\}}{n+1}$$ I think you would do better to write this: $$\frac1{n+1},\cdots,\frac n{n+1}$$

Note that there are no curly braces, which would imply that the result was a set, rather than a sequence.

Perhaps you could write the first one if you first explained that it means the second one.

My suggestion does not imply $n\ne 1$. $n=1$ is perfectly okay, and in that case the expression means a sequence with one element.

R most likely generates an empty sequence when $n=0$; check this. If not, mention it explicitly. Depending on your audience, you might want to mention it anyway.

-
Would a specific example, e.g. $\{0.2,0.4,0.6,0.8\}$, require curly braces? – Abe Jun 7 '12 at 0:35
I wouldn't. I would use some other sort of braces. – MJD Jun 7 '12 at 1:35