WOLFRAM

RankedMax[list,n]

gives the n^(th) largest element in list.

RankedMax[list,-n]

gives the n^(th) smallest element in list.

Details

Examples

open allclose all

Basic Examples  (4)Summary of the most common use cases

The second largest of three numbers:

Out[1]=1

The third largest of four numbers:

Out[1]=1

The second largest of a list of dates:

Out[1]=1
Out[2]=2

Plot the second-largest function over a subset of the reals:

Out[1]=1

Scope  (25)Survey of the scope of standard use cases

Numerical Evaluation  (7)

Evaluate the second largest of three numbers:

Out[1]=1

The fourth largesti.e the smallestof four numbers:

Out[4]=4

The second smallest of five numbers:

Out[1]=1

The fourth smallest of five numbers:

Out[2]=2

The fifth smallesti.e. the largestof five numbers:

Out[3]=3

Evaluate to high precision:

Out[1]=1
Out[2]=2

Evaluate efficiently at high precision:

Out[1]=1
Out[2]=2

RankedMax of WeightedData ignores the weights:

Out[2]=2
Out[3]=3

Compute ranked max of dates:

Out[2]=2
Out[3]=3

Compute the ranked max of times:

Out[1]=1
Out[2]=2

List of times with different time zone specifications:

Out[3]=3
Out[4]=4

Specific Values  (4)

Values at infinity:

Out[2]=2
Out[4]=4

Evaluate symbolically:

Out[1]=1

Solve equations and inequalities:

Out[1]=1

Find a value of x for which RankedMax[{Sin[x],Cos[x],Exp[x]},2]1:

Out[1]=1
Out[2]=2

Visualization  (3)

Plot RankedMax of several functions:

Out[1]=1

Plot RankedMax in three dimensions:

Out[1]=1

Plot RankedMax of three functions in three dimensions:

Out[1]=1

Function Properties  (8)

RankedMax is only defined for real-valued inputs:

Out[5]=5

The range of RankedMax is real numbers:

Out[1]=1

Basic symbolic simplification is done automatically:

Out[1]=1
Out[2]=2

Multi-argument ranked RankedMax is generally not an analytic function:

Out[1]=1

It will have singularities where the functions cross, but it will be continuous:

Out[2]=2
Out[3]=3

is neither nondecreasing nor nonincreasing:

Out[1]=1

is not injective:

Out[1]=1
Out[2]=2

is not surjective:

Out[1]=1
Out[2]=2

is non-negative:

Out[1]=1

Series and Integration  (3)

Series expansion of the second-largest function at the origin:

Out[8]=8

Asymptotic expansion at Infinity:

Out[1]=1

Integrate expressions involving RankedMax:

Out[1]=1
Out[2]=2

Applications  (7)Sample problems that can be solved with this function

Plot the bivariate RankedMax functions:

Out[1]=1

Plot the contours of bivariate and trivariate RankedMax functions:

Out[1]=1
Out[2]=2

RankedMax[{y1,,yn,x},k] as a function of x:

Out[1]=1
Out[2]=2

Compute the expectation of the second smallest (median) variable:

Out[1]=1

Alternatively, use OrderDistribution:

Out[2]=2

Compute the probability of the second smallest variable being less than 1:

Out[1]=1
Out[2]=2

Find the height of the fourth tallest child in a class:

Out[2]=2
Out[3]=3
Out[4]=4

Find the second-longest border of Germany:

Out[1]=1
Out[2]=2

Find which country it is:

Out[3]=3

Properties & Relations  (6)Properties of the function, and connections to other functions

RankedMax[{x1,,xm},1] is equivalent to Max[x1,,xm]:

Out[1]=1

RankedMax[{x1,,xm},m] is equivalent to Min[x1,,xm]:

Out[1]=1

RankedMax[{x1,,xm},k] is equivalent to RankedMin[{x1,,xm},m-k+1]:

Out[1]=1
Out[2]=2

RankedMax[{x1,,xm},n] is equivalent to Quantile[{x1,,xm},(m-n+1)/m]:

Out[2]=2

RankedMax[{x1,,xm},n] is equivalent to Sort[{x1,,xm},Greater]n:

Out[2]=2

The equivalent Piecewise function has disjoint piecewise case domains:

Out[2]=2
Out[3]=3

Algebraically prove the piecewise case domains are disjoint:

Out[4]=4

Visually show it:

Out[5]=5
Out[6]=6

Algebraically prove the piecewise case domains are pairwise disjoint:

Out[7]=7

Visually show it:

Out[8]=8

Neat Examples  (2)Surprising or curious use cases

Two-dimensional sublevel sets:

Out[1]=1
Out[2]=2

Three-dimensional sublevel sets:

Out[1]=1
Out[2]=2
Out[3]=3
Wolfram Research (2010), RankedMax, Wolfram Language function, https://reference.wolfram.com/language/ref/RankedMax.html (updated 2024).
Wolfram Research (2010), RankedMax, Wolfram Language function, https://reference.wolfram.com/language/ref/RankedMax.html (updated 2024).

Text

Wolfram Research (2010), RankedMax, Wolfram Language function, https://reference.wolfram.com/language/ref/RankedMax.html (updated 2024).

Wolfram Research (2010), RankedMax, Wolfram Language function, https://reference.wolfram.com/language/ref/RankedMax.html (updated 2024).

CMS

Wolfram Language. 2010. "RankedMax." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2024. https://reference.wolfram.com/language/ref/RankedMax.html.

Wolfram Language. 2010. "RankedMax." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2024. https://reference.wolfram.com/language/ref/RankedMax.html.

APA

Wolfram Language. (2010). RankedMax. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/RankedMax.html

Wolfram Language. (2010). RankedMax. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/RankedMax.html

BibTeX

@misc{reference.wolfram_2025_rankedmax, author="Wolfram Research", title="{RankedMax}", year="2024", howpublished="\url{https://reference.wolfram.com/language/ref/RankedMax.html}", note=[Accessed: 27-April-2025 ]}

@misc{reference.wolfram_2025_rankedmax, author="Wolfram Research", title="{RankedMax}", year="2024", howpublished="\url{https://reference.wolfram.com/language/ref/RankedMax.html}", note=[Accessed: 27-April-2025 ]}

BibLaTeX

@online{reference.wolfram_2025_rankedmax, organization={Wolfram Research}, title={RankedMax}, year={2024}, url={https://reference.wolfram.com/language/ref/RankedMax.html}, note=[Accessed: 27-April-2025 ]}

@online{reference.wolfram_2025_rankedmax, organization={Wolfram Research}, title={RankedMax}, year={2024}, url={https://reference.wolfram.com/language/ref/RankedMax.html}, note=[Accessed: 27-April-2025 ]}