Problem on IntervalUnion[]

IntervalUnion[Table[Interval[{1 + 1/n, n + 2}], {n, 1, 10000}]]
IntervalUnion @@ Table[Interval[{1 + 1/n, n + 2}], {n, 1, 10000}]

I am really new to Mathematica, so it maybe really simple,

I cant understand, why the first line does not work, but the second do.

Is there a way to use “infinity”?

I want to do

IntervalUnion @@ Table[Interval[{1 + 1/n, n + 2}], {n, 1, Infinity}]

Thanks

IntervalUnion[] acts on a sequence of intervals, not on a list of intervals. To generate a sequence out of a list one does

In[66]:= IntervalUnion[
Sequence @@ Table[Interval[{1 + 1/n, n + 2}], {n, 1, 100}]]
Out[66]= Interval[{101/100, 102}]

the second form works because the Apply[] operator replaces the head (List) of Table[Interval[{1 + 1/n, n + 2}], {n, 1, 10000}] with IntervalUnion: that way the argument of IntervalUnion[] becomes a sequence, as is usually the case in mathematical notation: One has

Sin[x]

not

Sin[{x}]

Second thing, the way to use “infinity” is to write Infinity:

In[68]:= IntervalUnion[Sequence@@Table[Interval[{1+1/n,n+2}],{n,1,Infinity}]]

During evaluation of In[68]:= Table::iterb: Iterator {n,1,\[Infinity]} does not have appropriate bounds. >>
During evaluation of In[68]:= Table::iterb: Iterator {n,1,\[Infinity]} does not have appropriate bounds. >>

Out[68]= IntervalUnion[Interval[{1+1/n,2+n}],{n,1,\[Infinity]}]

but it’s not possible here because Table[] dislikes unbounded iterators for good reasons (computing time, memory, …) and on the other hand the result is simple

Interval[{1,\[Infinity]}]

Please note, there are different types of Infinity:

In[69]:= Names["*Infinity*"]
Out[69]= {"ComplexInfinity", "DirectedInfinity", "Infinity"}

check them out! As an oversimplified example, you can do

In[70]:= Limit[Exp[-\[Alpha] x], x -> Infinity,  Assumptions -> \[Alpha] > 0]
Out[70]= 0

In[72]:= Sum[1/n^2, {n, 1, Infinity}]
Out[72]= \[Pi]^2/6

I think I understand what you are saying about the fisrt part now. Thanks.

Secondly, so there is no way to do this? I knew that the result is

Interval[{1,\[Infinity]}]

But, can we ask Mathematica to tell me that?

Of course you can ask Mathematica to tell you, but not with an infinite iterator in Table[] because that launches the actual construction of the table you will never live long enough to see it completing. Sorry, the world can be so not fair. Because both boundaries are strictly monotoneous, one can type

In[83]:= IntervalUnion[
Interval[Limit[#, n -> Infinity] & /@ {1 + 1/n, n + 2}]]
Out[83]= Interval[{1, \[Infinity]}]

but isn’t it ridiculous?