1
$\begingroup$

This question already has an answer here:

I have a table for example:

t = Table[k,{k,5}]

which returns

{1,2,3,4,5}

and for every element in this table I want to check when it is $\leq 1 + a$.

I used the Reduce commend as Reduce[t<1+f,f] but it doesn't work. How can I do that, without writing all inequalities separately ?

$\endgroup$

marked as duplicate by Artes, m_goldberg, Sjoerd C. de Vries, rm -rf Dec 9 '13 at 19:01

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • $\begingroup$ Look at Map. $\endgroup$ – rcollyer Dec 8 '13 at 23:33
  • $\begingroup$ Do you want all those inequalities to hold simultaneously? $\endgroup$ – Dr. belisarius Dec 8 '13 at 23:37
  • $\begingroup$ @belisarius Yes $\endgroup$ – Ziva Dec 8 '13 at 23:40
  • $\begingroup$ Then look at the Edit in my answer $\endgroup$ – Dr. belisarius Dec 8 '13 at 23:46
1
$\begingroup$
Thread[Array[# &, 5] <= 1 + a]
(*
 {1 <= 1 + a, 2 <= 1 + a, 3 <= 1 + a, 4 <= 1 + a, 5 <= 1 + a}
*)

Edit

Probably you want something like

t = Table [k, {k,5}];
Reduce[And @@ Thread[t  <= 1 + a], a]
(*
a >= 4
*)

But I'm not quite sure

$\endgroup$
  • $\begingroup$ Or Range[] or Table[] instead of Array[] $\endgroup$ – Dr. belisarius Dec 8 '13 at 23:34
  • $\begingroup$ the table which I wrote was only a suggestion. I want to reduce a table of values which have very different valueslike 0.0005,0.678,0.98999,1,456. And in your solution, can I do something like this? And I want to hold all those inequalities simultaneously $\endgroup$ – Ziva Dec 8 '13 at 23:46
  • $\begingroup$ @Ziva Yes. Take a look at the EDIT $\endgroup$ – Dr. belisarius Dec 8 '13 at 23:47
0
$\begingroup$
f[a_] := Map[Reduce[# <= a] &, Table[k, {k, 5}]]

f[3]

{True, True, True, False, False}
$\endgroup$
0
$\begingroup$

What you want to do is to check whether something (x) is less than 1+a. A simple approach is to make this a function:

f[x_, a_] := x < 1 + a

Now you can observe that f[10,6] is False and f[10,11] is True. Too apply this to a long list, use Map:

list = Range[10];
f[#, 3] & /@ list
{True, True, True, False, False, False, False, False, False, False}

The abbreviated form f[#, 3] & /@ list is short for the Map function.

$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.