1
$\begingroup$

Suppose I need to define a matrix of the form

{{a, b, Reduce[a<b]}, {c, d, Reduce[c<d]}, {e, f, Reduce[e<f]}}

but with a lot more rows and automating the Reduce argument by making it be "first element of this row < second element of this row".

How would I do that? I understand the question doesn't make much sense in a coding grammar or optimization way, but I would like to learn how to evaluate "this row" in this sense.

$\endgroup$

1 Answer 1

1
$\begingroup$

Assuming you have the matrix with the last column missing, you can Map or Apply over the individual rows of the matrix & add some new columns. Here are two possible approaches:

{##, Reduce[Less@##]} & @@@ {{a, b}, {c, d}, {e, f}}
(* {{a, b, b ∈ Reals && a < b}, {c, d, d ∈ Reals && c < d}, {e, f, f ∈ Reals && e < f}} *)
Append[#, Reduce[Less @@ #]] & /@ {{a, b}, {c, d}, {e, f}}
(* same output *)
$\endgroup$

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.