4
$\begingroup$

$$\sum_{k=1}^na_k=a_1+...+a_n$$ $$\prod_{k=1}^na_k=a_1\cdot...\cdot a_n$$ $$\large{?}\small{_{k=1}^na_k=a_1~\&\&...\&\& ~a_n}$$ What in mathematica would allow me to index logical statements in an operation like AND or OR? I'm trying to solve a system of n vector equations, so I can't afford to type them all in manually into the argument of Solve[].

Someone suggested that I take the product of the equations, i.e. if $a_i=(x_i=y_i)$, then $$a_1~\&\&...\&\& ~a_n\leftrightarrow \prod_{k=1}^n(x_i-y_i)$$ However, $x_i,y_i$ are vectors, and even their lengths vary, depending on $i$. Does anyone know how to solve this issue?

$\endgroup$
1
  • 5
    $\begingroup$ If you apply And: And @@ {a1, a2, a3} you'll get a1 && a2 && a3. (a1 && a2 && a3)[[2]] yields a2. $\endgroup$
    – Artes
    Commented Jan 19, 2014 at 22:57

2 Answers 2

4
$\begingroup$

Artes solution is probably the easiest

And @@ Array[b, 10]

but if you like the syntax of Sum, you can use it and then transform Plus into And

Sum[b[i], {i, 1, 10}] /. Plus -> And

Both of these give the logical And of the entries in the array b:

b[1] && b[2] && b[3] && b[4] && b[5] && b[6] && b[7] && b[8] && b[9] && b[10]
$\endgroup$
0
2
$\begingroup$

And @@ Outer[f, Range[10]] gets the job done.

$\endgroup$
2
  • $\begingroup$ I feel it would be "easier" to write And @@ (f /@ Range[10]) here. Outer with 2 arguments is Map. Or even And @@ f /@ Range[10] if you are feeling right associative :P. $\endgroup$ Commented Jan 20, 2014 at 9:14
  • $\begingroup$ @JacobAkkerboom: You are tempting me to post the TuringMachine implementation... $\endgroup$
    – ciao
    Commented Jan 20, 2014 at 9:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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