How this calculation works
Evaluate the extended-real Fenchel conjugate of a maximum of affine functions, including its finite domain and equality witnesses.
f*(y)=sup_x(yᵀx-f(x))=min{−Σλ_i b_i: λ_i≥0, Σλ_i=1, Σλ_i a_i=y}, with +infinity when y is outside conv{a_i}.A worked example
For f(x)=max(-x,x+1), f*(y)=-(y+1)/2 for -1≤y≤1 and +infinity otherwise. At y=0, f*=−1/2 and x=−1/2 is a Fenchel equality witness.
Good to know
One to three coordinates,2–20 affine pieces with rational coefficients, and up to20 queried dual points. Exact LP evaluation and convex-hull membership; report positive infinity outside the slope hull. State subgradient/witness conventions and handle redundant pieces and boundary slopes. Do not extend to arbitrary nonconvex symbolic expressions or require strict differentiability.
Reference: Boyd and Vandenberghe, Convex Optimization (opens in a new tab) ↗
Enter a convex max-affine function
Each piece consists of a rational slope vector and rational intercept. The function value at any x is the maximum of all those affine values. This construction is convex automatically, including when some pieces are redundant or coincide. It accepts one through three coordinates and two through twenty pieces without requiring differentiability at their intersections.
Queries are dual vectors y with the same dimension as the slopes, not ordinary points at which f is evaluated. The conjugate changes the variable and can take positive infinity. Keeping x and y conceptually separate prevents a common mistake: interpreting a finite value of f at a point as evidence that the conjugate must be finite at the same numeric coordinates.
Compare this with the Linear and mixed integer programming calculator from constraints. Evaluates the extended-real convex conjugate and its domain for f(x)=max_i(a_i dot x+b_i), with dual slope mixtures and a Fenchel equality witness. Existing LP is a solver dependency, not a convex-function duality tool; no existing page constructs this conjugate.
Understand the supremum definition
For a chosen y, subtract f(x) from the linear functional y dot x and maximize over all real x. If the linear functional can outgrow f in some direction, the supremum is positive infinity. Otherwise the best vertical offset of a supporting affine function determines the finite conjugate value. Negative conjugate values are entirely possible and do not indicate a failed optimization.
The finite domain is exactly the convex hull of the entered slope vectors. Intercepts change finite values but do not enlarge that slope hull. Boundary slopes remain legitimate queries, and a lower-dimensional hull can have a finite domain even when it has no interior in the surrounding coordinate space. Membership must therefore be tested in its actual affine span rather than by assuming full dimension.
Use slope mixtures for exact evaluation
A convex combination of slopes represents the queried y when nonnegative mixture weights sum to one. Among all such combinations, minimize the negative weighted intercept. This rational linear program evaluates the conjugate directly and supplies a dual mixture witness. If no mixture exists, the query lies outside the slope hull and the extended-real answer is positive infinity.
A compatible primal witness x satisfies Fenchel equality, meaning f(x)+f*(y)=x dot y. It may lie at a kink where several pieces are active, and it need not be unique. The implementation should distinguish a mixture witness from a primal equality witness and verify each in the correct coordinate space. Redundant affine pieces can change mixture representations while leaving the conjugate function unchanged.
Check the two-piece default
The slopes are minus one and plus one, with intercepts zero and one. To obtain a slope y between minus one and one, the weight of the second piece is (y+1)/2 and the first weight is (1-y)/2. The negative weighted intercept is therefore minus (y+1)/2, yielding the stated affine conjugate on its finite interval.
The two original pieces intersect at x=-1/2, where f is one half. At y=0, the conjugate is minus one half and the equality f+f*=x*y becomes zero equals zero. More generally the same kink witnesses every interior dual slope. At y=2 no convex mixture of the two slopes is possible, and taking x toward positive infinity makes y*x-f(x) diverge.
Read supporting lines and dual domain
The graph illustration shows a V-shaped max-affine function with its corner shifted from the origin, alongside the conjugate interval. A selected supporting slope identifies a point in the dual domain, while the supporting line’s offset determines the conjugate value. The conjugate graph can be affine over an interval even though the original function is nonsmooth at a single point.
The picture is specific to one coordinate. In higher dimensions the slope hull is a polygon, segment, polytope or lower-dimensional affine subset, depending on the supplied slopes. A query outside that hull is not a numerical overflow or a large finite penalty. Positive infinity is the mathematically correct extended-real value and should remain distinct from parser failure or a solver work limit.
Verify equality and handle degeneracy
For each finite result, check nonnegative mixture weights, their sum, their slope combination and the resulting objective. If a primal witness is returned, independently evaluate every affine piece, take their maximum and verify Fenchel equality exactly. These checks expose sign mistakes in intercept handling that can leave hull membership and mixture weights apparently correct.
At boundary queries or redundant pieces, an LP can have many optimal mixtures. Deterministic tie-breaking improves reproducibility but must not be presented as a unique mathematical representation. The calculator accepts at most twenty queries and bounded rational inputs. Exact fraction or LP limits leave an unresolved query status; they should not be converted into positive infinity, which specifically denotes an unbounded conjugate supremum.
Choose conjugacy rather than an inverse function
A Fenchel conjugate is not the inverse of f and does not require f to be one-to-one. It organizes supporting slopes and offsets and is useful in convex duality, subgradient relations and optimization reformulations. The equality condition y in the subgradient of f at x remains meaningful at corners, where an ordinary derivative is absent.
This page is limited to finite maxima of affine pieces. Arbitrary nonconvex symbolic formulas, infinite families of pieces and general smooth convex functions need other constructions. Save the piece list, slope convention and extended-real domain with the query results. Reporting only finite values would hide a central part of the conjugate: the set of dual directions in which a finite supporting offset exists.
A few questions, answered
Can a conjugate be negative?
Yes. Intercepts can shift finite conjugate values below zero.
What does positive infinity mean?
The queried slope lies outside the slope hull, so the defining supremum is unbounded.
Must f be differentiable?
No. Subgradients and equality witnesses handle max-affine kinks directly.
Do redundant pieces matter?
They can change witness mixtures, but they do not change the represented function or its conjugate.