Advanced maths

Proximal operator and Moreau envelope calculator for convex piecewise quadratic functions

Compute the scalar proximal map and Moreau envelope of a closed convex piecewise-quadratic function using exact piece and kink candidates.

Your numbers

Calculated on your device. Your inputs aren’t sent to us.

Your result

Ready when you are

Enter your inputs and select Calculate.

Report an issue

Behind the numbers

How this calculation works

Compute the scalar proximal map and Moreau envelope of a closed convex piecewise-quadratic function using exact piece and kink candidates.

THE FORMULAprox_(λf)(v)=argmin_x[f(x)+(x-v)²/(2λ)]; e_λf(v)=min_x[f(x)+(x-v)²/(2λ)], with gradient (v-prox_(λf)(v))/λ.

A worked example

For f(x)=|x| and lambda=3/4, prox(v)=sign(v)max(|v|-3/4,0). At v=2 the prox is 5/4, the envelope is 13/8 and its gradient is 1.

Good to know

A scalar closed convex piecewise-quadratic function on consecutive rational intervals, up to12 pieces, optional finite domain endpoints, positive rational step parameter and up to100 query points. Verify continuity on adjacent finite pieces, nonnegative curvature and monotone one-sided slopes. Exact piece/kink minimizer selection; report envelope gradient and subgradient inclusion. Absolute-value, Huber and interval-indicator examples stay on this page.

Describe the function by consecutive pieces

Each JSON piece gives lower and upper endpoints and coefficients a,b,c for a*x²+b*x+c. A null endpoint denotes the corresponding infinity. Consecutive pieces meet at common breakpoints, and optional finite outer endpoints define a function that is positive infinity outside its domain. This extended-real interpretation permits interval-indicator functions without inventing a huge finite penalty.

The step parameter lambda must be positive. Queries are scalar v values, not proposed minimizers. The page accepts up to twelve pieces and one hundred query points. Every coefficient and finite endpoint uses rational input so the piece checks and candidate comparisons can be exact under the bounded parser. State the domain explicitly, since changing a finite endpoint can change the prox even far from a kink.

A nonsmooth function gives a smooth envelopef(x) = |x|Soft thresholdMoreau envelopeλ = 3/4; prox(2) = 5/4
Scroll across to see the full diagram.
The absolute-value prox has a threshold interval; the Moreau envelope rounds the original corner.

Compare this with the Convex quadratic programming calculator with constraints. Computes the resolvent/proximal map and smooth Moreau envelope of an entered nonsmooth convex function, including kink threshold regions. Existing smooth QP solves one globally quadratic objective; it does not accept piecewise functions or construct a prox/envelope map.

Check convexity before computing a prox

Within each finite piece, nonnegative quadratic curvature requires a≥0. At adjoining finite pieces, values must match and one-sided slopes must be nondecreasing across the breakpoint. These conditions establish the supported closed convex piecewise-quadratic form. A downward slope jump is nonconvex even when each individual quadratic is convex on its own interval.

The added squared-distance term has strictly positive curvature, so the prox minimizer is unique for every accepted query. That uniqueness comes from the regularized objective, not from strict convexity of f itself. An absolute value, a constant function on an interval or a piece with zero curvature can still have a perfectly well-defined unique prox after the quadratic term is added.

Solve interiors, kinks and finite endpoints

Inside a piece, stationarity gives x=(v-lambda*b)/(1+2*lambda*a). This candidate is admissible only when it lies in that piece’s interval. Breakpoints and finite domain endpoints must also be considered because the minimizer can occur where no ordinary derivative exists. Compare the regularized objective values exactly among all admissible candidates.

A useful certificate is the subgradient inclusion (v-x)/lambda in the subgradient of f at x. At an interior smooth point this is an equality with f prime. At a kink it means the value lies between the left and right slopes; at a finite domain endpoint the subgradient also includes the appropriate normal-cone half-line. Ignoring those endpoint normals can incorrectly reject a valid projection.

Verify soft thresholding in the default

The default function is minus x on the nonpositive half-line and plus x on the nonnegative half-line. Its subgradient at zero is the interval [-1,1]. For |v|≤lambda, choosing x=0 satisfies the inclusion because v/lambda lies inside that interval. Outside the interval, stationarity on the correct linear piece gives v-lambda for positive v and v+lambda for negative v.

At lambda=3/4 and v=2, the minimizer is 5/4. Its function value is 5/4 and the distance penalty is (3/4)² divided by 3/2, namely 3/8. Their sum is 13/8. At v=1/2 the minimizer is zero, the envelope is 1/6 and the gradient is 2/3. These checks exercise both an interior linear piece and the kink region.

Understand the smooth Moreau envelope

The original function can have corners while the envelope has a continuous first derivative. Its gradient is the residual between the query and prox point divided by lambda. For absolute value, the envelope is quadratic near zero and linear outside the threshold interval, with matching slopes at the transitions. It should not be confused with simply plotting f at the prox point.

The proximal map is nonexpansive, and in the scalar convex setting it is monotone. These identities provide useful cross-query tests in addition to exact example values. The envelope’s smoothness does not imply that its second derivative is continuous everywhere. Threshold boundaries can still separate regions with different curvature, so a piecewise description remains more informative than calling the result globally quadratic.

Read the three-part illustration

The illustration shows the original absolute-value corner, the flat central region of the soft-threshold map and the rounded central portion of the envelope. Each panel uses a different vertical quantity. The prox graph reports a decision x for each input v, whereas the envelope graph reports a minimized objective value, and its derivative comes from their difference.

Increasing lambda widens the threshold interval for this example and strengthens the influence of the original function relative to the distance term. That behavior follows from the convention f(x)+(x-v)²/(2lambda). Some software writes the regularization parameter in a different position. Always translate that convention before comparing outputs; an inverted step parameter can produce internally consistent but numerically different thresholds.

Choose the resolvent rather than general minimization

A generic quadratic-programming solver handles one globally quadratic objective with affine constraints. This tool accepts a convex piecewise function and constructs its proximal response and envelope at several query points, including kink thresholds. Absolute value, Huber-like losses and interval projections are examples of the same operation and belong under the same mathematical interface.

The calculator rejects gaps between pieces, discontinuous finite joins and decreasing one-sided slopes. It does not search a nonconvex regularized function or add hidden smoothing to repair invalid input. Save the piece convention, lambda and domain with the output. Exact candidate selection resolves the entered rational model, while any approximation used to obtain those pieces remains a separate modeling issue.

A few questions, answered

Is the prox unique?

Yes. The added positive quadratic makes the accepted convex objective strictly convex.

What does null mean at an endpoint?

It denotes an infinite outer endpoint of the function domain.

Is the envelope f(prox(v))?

No. It also includes the squared-distance penalty at the minimizing point.

Can a kink be optimal?

Yes. Its subgradient interval can satisfy the optimality inclusion for a whole range of queries.

Find your calculator

Start typing to explore the library.