- See Also
-
Related Guides
- Math & Counting Operations on Lists
- Numerical Functions
- Elementary Functions
- Elements of Lists
- Numerical Data
- Descriptive Statistics
- Mathematical Functions
- Computation with Structured Datasets
- Robust Descriptive Statistics
- GPU Computing
- Tabular Transformation
- GPU Computing with NVIDIA
- GPU Computing with Apple
- Tech Notes
-
- See Also
-
Related Guides
- Math & Counting Operations on Lists
- Numerical Functions
- Elementary Functions
- Elements of Lists
- Numerical Data
- Descriptive Statistics
- Mathematical Functions
- Computation with Structured Datasets
- Robust Descriptive Statistics
- GPU Computing
- Tabular Transformation
- GPU Computing with NVIDIA
- GPU Computing with Apple
- Tech Notes
Max
Examples
open all close allBasic Examples (3)
Scope (29)
Numerical Evaluation (7)
Max[5.56, -4.8, 7.3]N[Max[1 / 7, 17 / 11, 1], 50]The precision of the output tracks the precision of the input:
Max[5.210000045000110400, 1]Evaluate efficiently at high precision:
Max[47, 5, 148`100]//TimingMax[15 / 71, 5, 1`100000];//TimingThe maximum of all elements of a matrix:
mat = {{-1, 0, 1, 2}, {0, 2, 4, 6}, {-3, -2, -1, 0}};Max[mat]Max /@ matMax /@ Transpose[mat]For Interval objects, Max gives the maximum element in all intervals:
Max[Interval[{1, 3}], Interval[{-3, 5}]]For CenteredInterval objects, Max[Δ1,Δ2] gives an interval containing Max[a1,a2] for any ai∈Δi:
Max[CenteredInterval[2, 1], CenteredInterval[1, 4]]Compute average-case statistical intervals using Around:
Max[{ 1, Around[-1.1, 0.01]}]Compute the elementwise values of an array using automatic threading:
Max[2, 3, {{1 / 2, -1}, {-5 / 3, 1 / 2}}]Or compute the matrix Max function using MatrixFunction:
MatrixFunction[Max[2, 3, #]&, {{1 / 2, -1}, {-5 / 3, 1 / 2}}]//FullSimplifySpecific Values (5)
Values of Max at fixed points:
Max[{E, Pi, 2}]Max[∞, 5]Max[-∞, 5]PiecewiseExpand[Max[ {x, y, z}], -2 < x < 2, 3 < y < 4]Solve equations and inequalities:
Reduce[{Max[Sin[x], Cos[x]] > 0, 0 < x < 20}, x]Find a value of x for which Max[{Sin[x],Cos[x]}]1:
xval = x /. FindRoot[Max[{Sin[x], Cos[x]}] == 1, {x, π / 2}]Plot[Max[{Sin[x], Cos[x]}], {x, -3, 5}, Epilog -> Style[Point[{xval, Max[{Sin[xval], Cos[xval]}]}], PointSize[Large], Red]]Visualization (3)
Plot the Max of several functions:
Plot[Max[Sin[x], Cos[x]], {x, 0, 2π}, PlotRange -> All]Plot Max in three dimensions:
Plot3D[Max[x, y], {x, -3, 3}, {y, -3, 3}, ColorFunction -> "BlueGreenYellow"]Plot Max of two functions in three dimensions:
Plot3D[Max[Tan[x], Tan[y]], {x, -3, 3}, {y, -3, 3}, ColorFunction -> "BlueGreenYellow"]Function Properties (9)
Max is only defined for real-valued inputs:
FunctionDomain[Max[x1, x2], {x1, x2}]FunctionDomain[Max[x1, x2], {x1, x2}, Complexes]The range of Max is all real numbers:
FunctionRange[Max[x1, x2], {x1, x2}, y]Max effectively flattens out all lists:
Max[{{3, 4, 1}}, {2, 2}, 7]Basic symbolic simplification is done automatically:
Max[x, y, Max[x, z]]Additional simplification can be done using Simplify:
Simplify[Max[1 - x, x, 1 + x]]Multi-argument Max is generally not an analytic function:
FunctionAnalytic[Max[ x, x ^ 2], x]It will have singularities where the arguments cross, but it will be continuous:
FunctionSingularities[Max[x, x ^ 2], x]//ReduceFunctionDiscontinuities[Max[x, x ^ 2], x]Max can have any monotonicity depending on its arguments:
FunctionMonotonicity[Max[x, x ^ 2], x]FunctionMonotonicity[Max[x, -x ^ 2], x]FunctionMonotonicity[Max[-x, -x ^ 2], x]FunctionSurjective[Max[x, x ^ 2], x]Plot[{Max[x, x ^ 2], -1}, {x, -2, 2}]Max can have any sign depending on its arguments:
FunctionSign[Max[x, x ^ 2], x]FunctionSign[Max[x, -x ^ 2], x]FunctionSign[Max[-RealAbs[x], -x ^ 2], x]Differentiation and Integration (5)
First derivative with respect to x:
D[Max[x, y], x]Higher derivatives with respect to x:
Table[D[Max[x, y], {x, k}], {k, 1, 3}]//FullSimplifyFormula for the ![]()
derivative with respect to x:
D[Max[x, y], {x, k}]// FullSimplifyCompute the indefinite integral using Integrate:
Integrate[Max[x, y, z], x]FullSimplify[D[%, x]]Integrate[Max[x, y], {x, 0, 4}]Integrate[Max[Sin[x], Cos[x]], {x, 0, Pi}]Integrate[Exp[Max[x, a - x]], {x, 0, 1}]Applications (7)
Data Processing (2)
Create a function that computes the cumulative max of a list:
CumulativeMax[list_List] := FoldList[Max, First[list], Rest[list]]Use on some different types of data:
data1 = Table[Sin[x] + x Sin[Sqrt[2]x], {x, 0, 25, .1}];ListLinePlot[{data1, CumulativeMax[data1]}]Create a function that computes the max of a sequence given by a function:
ProceduralMax[f_, {k_, kmin_, kmax_, dk_}] :=
Module[{val = -∞},
Do[val = Max[val, f], {k, kmin, kmax, dk}];
val
]Try it for some different sequences:
ProceduralMax[Sin[x] + x Sin[Sqrt[2]x], {x, 0., 10^6, 1.}]Function Processing (4)
Create a function that gives the positive part and another that gives the negative part:
PositivePart[f_] := Max[0, f];
NegativePart[f_] := Min[0, f];{Plot[PositivePart[Sin[x]], {x, 0, 5π}, ...],
Plot[NegativePart[Sin[x]], {x, 0, 5π}, ...]}The max of non-negative functions will be another non-negative function. Use that to generate interesting positive functions. These are all non-negative functions:
FunctionSign[#, {x, y}]& /@ {Exp[-(x^2 + y^2)], Sin[x + y] + 1}The max will also be non-negative:
FunctionSign[Max[{Exp[-(x^2 + y^2)], Sin[x + y] + 1}], {x, y}]Plot3D[Max[{Exp[-(x^2 + y^2)], Sin[x + y] + 1}], {x, -2, 2}, {y, -2, 2}]FunctionSign[#, {x, y}]& /@ {Sin[x - y] + 1, Sin[x + y] + 1}Plot3D[Max[{Sin[x - y] + 1, Sin[x + y] + 1}], {x, -5, 5}, {y, -5, 5}]The max of increasing functions will be another increasing function. Use that to generate interesting increasing functions:
FunctionMonotonicity[#, x]& /@ {x, x^3, (x - 1)^5}Plot[Max[{x, x^3, (x - 1)^5}], {x, -2, 2}]The max of convex functions will be another convex function. Use that to generate interesting convex functions:
FunctionConvexity[#, {x, y}]& /@ {x^2 + y^2, Exp[x + y] - 2, Exp[-x + y] - 2, Exp[-x - y] - 2, Exp[x - y] - 2}Plot3D[Max[{x^2 + y^2, Exp[x + y] - 2, Exp[-x + y] - 2, Exp[-x - y] - 2, Exp[x - y] - 2}], {x, -2, 2}, {y, -2, 2}, MeshFunctions -> {#3&}]Geometric Regions (1)
Max and min can be used to model Boolean operations for implicit regions. The intersection
is equivalent to
and, similarly, the union
is equivalent to
.
Consider the following two regions:
RegionPlot[{x^3 + y <= 0, y^3 + x <= 0}, {x, -2, 2}, {y, -2, 2}]This is their intersection done with either Boolean operations or max:
{RegionPlot[x^3 + y <= 0∧y^3 + x <= 0, {x, -2, 2}, {y, -2, 2}],
RegionPlot[Max[{x^3 + y, y^3 + x}] <= 0, {x, -2, 2}, {y, -2, 2}]}This is their union done with either Boolean operations or min:
{RegionPlot[x^3 + y <= 0∨y^3 + x <= 0, {x, -2, 2}, {y, -2, 2}],
RegionPlot[Min[{x^3 + y, y^3 + x}] <= 0, {x, -2, 2}, {y, -2, 2}]}Properties & Relations (6)
With no arguments, Max returns -Infinity:
Max[]Max[Max[z, y], x]Use PiecewiseExpand to express Max and Min as explicit cases:
PiecewiseExpand[Max[Min[x, y], z]]Use FullSimplify to simplify Max expressions:
FullSimplify[Max[x, y] - Max[-x, -y]]FullSimplify[Min[x, y] - (x + 2y - Sqrt[(x - y)^2]) / 2, Element[{x, y}, Reals]]Maximize a function containing Max:
Maximize[Max[-x ^ 2 + 2x + 2, -x ^ 4 + 3 x + 2], x]Max can be differentiated:
Max'[x]Derivative[1, 0][Max]Possible Issues (2)
Neat Examples (2)
Two-dimensional sublevel sets:
Table[RegionPlot[Max[x, y] < t, {x, -2, 2}, {y, -2, 2}, PlotLabel -> Max[x, y] < t], {t, {-1, 0, 1}}]Table[RegionPlot[Max[x, y] > t, {x, -2, 2}, {y, -2, 2}, PlotLabel -> Max[x, y] > t], {t, {-1, 0, 1}}]Three-dimensional sublevel sets:
Table[RegionPlot3D[Max[x, y, z] < t, {x, -2, 2}, {y, -2, 2}, {z, -2, 2}, PlotLabel -> Max[x, y, z] < t], {t, {-1, 0, 1}}]Table[RegionPlot3D[Max[x, y, z] > t, {x, -2, 2}, {y, -2, 2}, {z, -2, 2}, PlotLabel -> Max[x, y, z] > t], {t, {-1, 0, 1}}]Tech Notes
Related Guides
-
▪
- Math & Counting Operations on Lists ▪
- Numerical Functions ▪
- Elementary Functions ▪
- Elements of Lists ▪
- Numerical Data ▪
- Descriptive Statistics ▪
- Mathematical Functions ▪
- Computation with Structured Datasets ▪
- Robust Descriptive Statistics ▪
- GPU Computing ▪
- Tabular Transformation ▪
- GPU Computing with NVIDIA ▪
- GPU Computing with Apple
History
Introduced in 1988 (1.0) | Updated in 2003 (5.0) ▪ 2021 (13.0)
Text
Wolfram Research (1988), Max, Wolfram Language function, https://reference.wolfram.com/language/ref/Max.html (updated 2021).
CMS
Wolfram Language. 1988. "Max." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2021. https://reference.wolfram.com/language/ref/Max.html.
APA
Wolfram Language. (1988). Max. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/Max.html
BibTeX
@misc{reference.wolfram_2026_max, author="Wolfram Research", title="{Max}", year="2021", howpublished="\url{https://reference.wolfram.com/language/ref/Max.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_max, organization={Wolfram Research}, title={Max}, year={2021}, url={https://reference.wolfram.com/language/ref/Max.html}, note=[Accessed: 13-June-2026]}