A (k) =the closed interval [-10+Sin [k], 10+Sin [k]] How do I can create a list of the first 20 of such interval The find the intersection of the first 14 of them
4 Answers
c = IntervalIntersection @@ (Array[ Interval[{-10 + Sin[#], 10 + Sin[#]}] &, {20}][[;; 14]])
Graphics[{Array[Line[{{-10 + Sin[#], #}, {10 + Sin[#], #}}] &, {14}],
Red, c /. Interval[{x_, y_}] -> Line@{{x, 0}, {y, 0}}}]
The code
ak = N[Table[Interval[{-10 + Sin[k], 10 + Sin[k]}], {k, 1, 20}]];
computes the first 20 as intervals. Remove the N[ ]
wrapper for the exact values. You can then compute the intersection of the first 14 as closed intervals with
IntervalIntersection @@ ak[[1;;14]]
Finally this is the correct intersection: Interval[{-9.00939, 9.00001}]
-
-
$\begingroup$ @Nana
@@
-Apply
. Difference between @ and @@. $\endgroup$– KubaCommented Dec 1, 2013 at 17:14 -
-
-
$\begingroup$ I'm really confuse now... what is the corect code in this case? $\endgroup$– maisCommented Dec 1, 2013 at 17:21
We can use properties of Interval
earlier:
f = Sin[#] + Interval[{-10, 10}]&;
IntervalIntersection @@ Array[f, 14] // N
Interval[{-9.00939, 9.00001}]
You can answer this question without knowing anything about interval functions: the intersection of all the intervals is the interval between (10-largest value of Sin) and (10+smallest value of Sin). With Sin assuming integer values between 1 and 14, this is:
{10 - Max[Sin[Range[14]]], 10 + Min[Sin[Range[14]]]}
{10 - Sin[14], 10 + Sin[11]}//N
{9.00939, 9.00001}