Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Imagine I have a matrix of the following form:

TestArray = $((a_1,b_1,...),(a_2,b_2,...),(a_3,b_3,...),...)$, where a specific example might be:

TestArray = $((10^6,1,...),(10^7,7,...),(10^3,4,...))$

In the above example, we have $Max[a_i] = 10^7$, and $Max[b_i] = 7$.

In a single line of Mathematica, how can I find the maximum $a_i$, $b_i$, etc.? Moreover, what is the most computationally efficient manner in which to do this?

share|improve this question
up vote 1 down vote accepted
 array = RandomInteger[10^5, {20, 5}];

 array // TableForm

enter image description here

 Max /@ Transpose@array
 (* {93950, 99694, 94568, 97340, 90524} *)


 #[[Ordering[#, -1]]][[1]] & /@ Transpose[array]
 (* {93950, 99694, 94568, 97340, 90524} *)
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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