0
|
3503 Views
|
3 Replies
|
1 Total Likes
View groups...
Share
GROUPS:

# Problem on IntervalUnion[]

Posted 11 years ago
 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
3 Replies
Sort By:
Posted 11 years ago
 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 typeIn[83]:= IntervalUnion[Interval[Limit[#, n -> Infinity] & /@ {1 + 1/n, n + 2}]]Out[83]= Interval[{1, \[Infinity]}] but isn't it ridiculous?
Posted 11 years ago
 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 isInterval[{1,\[Infinity]}]But, can we ask Mathematica to tell me that?
Posted 11 years ago
 IntervalUnion[] acts on a sequence of intervals, not on a list of intervals. To generate a sequence out of a list one doesIn[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]notSin[{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 simpleInterval[{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 doIn[70]:= Limit[Exp[-\[Alpha] x], x -> Infinity,  Assumptions -> \[Alpha] > 0]Out[70]= 0In[72]:= Sum[1/n^2, {n, 1, Infinity}]Out[72]= \[Pi]^2/6