Mathematical Background
One dimension
Paper
[1] K. Jung. Specular differentiation in one dimension: a quasi-mean value theorem, regularity, and discontinuities. arXiv preprint arXiv:2601.09900v5, 2026.
[2] K. Jung and J. Oh. Regular specular differentiation in Euclidean spaces. arXiv preprint arXiv:2210.06062v3, 2022.
Angular averaging
Specular differentiation uses the geometry of one-sided secant lines. Instead of averaging their slopes, it averages the angles they make with the horizontal axis and converts the resulting angle back into a slope. This construction extends classical differentiation to corners, certain vertical tangents, and some discontinuities.
Let \(f:I\to\mathbb{R}\), where \(I\) is an open interval, and let \(x\in I\). For sufficiently small \(h>0\), define the forward and backward difference quotients by
The angular mean of two finite slopes is
An equivalent algebraic expression is
The specular derivative is defined by
provided this limit exists as a finite real number. The limit is taken after combining the quotients. The two quotients do not need to converge separately.
Write \(\partial^+f(x)=f'_+(x)\) and \(\partial^-f(x)=f'_-(x)\) for the right and left derivatives, respectively. When both are finite, the definition gives
The identities \(\mathcal C(\alpha,\alpha)=\alpha\) and \(\mathcal C(\alpha,-\alpha)=0\) explain two basic features: the specular derivative agrees with the classical derivative wherever the latter exists, and opposite slopes give a horizontal specular tangent. Moreover, \(\mathcal C(\alpha,\beta)\) lies between its two arguments.
The regular case and its geometry
The regular theory of Jung and Oh calls \(f\) regularly specularly differentiable at \(x\) when both one-sided derivatives are finite. This condition implies continuity at \(x\). The general difference-quotient definition above agrees with the regular derivative at every such point.
The two one-sided tangent rays form the phototangent:
A circle centered at \((x,f(x))\) intersects these rays at two points. The chord joining them has a slope independent of the circle's radius. Its parallel translate through \((x,f(x))\) is the specular tangent line. This line acts as a mirror: the incident and reflected rays make equal angles with it.
Infinite slopes and oscillation
The angular formula extends \(\mathcal B\) and \(\mathcal C\) to infinite one-sided slopes using \(\arctan(\pm\infty)=\pm\frac{\pi}{2}\). For example,
If a finite specular derivative exists and either one-sided derivative exists in the extended real line, then the other one-sided derivative exists as well, and their angular mean equals the specular derivative. Two derivatives both equal to \(+\infty\), or both equal to \(-\infty\), cannot produce a finite specular derivative.
Classical and symmetric differentiation
The symmetric derivative averages the same difference quotients arithmetically:
When both one-sided derivatives are finite, this is their arithmetic mean. At a corner, that mean generally differs from the angular mean. For the function \(f(x)=\max\{x,0\}\),
For \(f(x)=|x|\), both generalized derivatives are zero at the origin, although the classical derivative does not exist there.
A vertical tangent can also have a finite angular average. Consider
Here \(\partial^+f(0)=+\infty\) and \(\partial^-f(0)=-1\), so \(f^{\sd}(0)=\sqrt2-1\). The symmetric derivative does not exist as a finite number. More generally, neither specular nor symmetric differentiability implies the other: angular cancellation and arithmetic cancellation can behave differently when the quotients oscillate.
The base-point value also matters. It cancels from the symmetric quotient, but generally remains relevant to the angular mean. For example, the step function with \(f(x)=0\) for \(x\leq0\) and \(f(x)=1\) for \(x>0\) has \(f^{\sd}(0)=1\). Changing only \(f(0)\) to \(\frac12\) makes both quotients tend to \(+\infty\), so no finite specular derivative remains at zero. Thus the definition applies directly at discontinuities and can depend on the assigned value of the function there.
Specular differentiation is nonlinear. The usual linearity and chain rules cannot be assumed, even though its value agrees with the classical derivative at every classically differentiable point.
Even multiplication by a constant need not commute with the derivative. For \(r(x)=\max\{x,0\}\),
The Quasi-Mean Value Theorem
Suppose \(a<b\), and let \(f:[a,b]\to\mathbb R\) be continuous on \([a,b]\) and specularly differentiable on \((a,b)\). Then there exist \(c_1,c_2\in(a,b)\) such that
This theorem retains the order information of the classical Mean Value Theorem: values of the specular derivative bound every secant slope. It does not require the secant slope to equal the specular derivative at one point.
Under the same continuity and specular differentiability assumptions, \(f\) is nondecreasing exactly when \(f^{\sd}\geq0\) throughout the interior, and nonincreasing exactly when \(f^{\sd}\leq0\). In particular, \(f^{\sd}\equiv0\) on \((a,b)\) if and only if \(f\) is constant on \([a,b]\).
For convex functions, the derivative also has a direct interpretation in convex analysis. Every real-valued convex function on an open interval is continuous and specularly differentiable, and
Consequently, \(f^{\sd}(x)\) belongs to the convex subdifferential \(\partial f(x)\) and satisfies
This gives a particular subgradient selected by angular averaging.
Continuity and classical regularity
Specular differentiability alone does not imply continuity or even Lebesgue measurability. Without either assumption, however, an everywhere specularly differentiable function has at most countably many discontinuities at which its specular derivative is nonzero. The restriction to nonzero derivatives is essential: there are nowhere-continuous, nonmeasurable functions with identically zero specular derivative.
For a continuous function \(f\) that is specularly differentiable throughout an open interval \(I\), stronger conclusions hold:
- \(f^{\sd}\) is a pointwise limit of continuous functions, hence is of Baire class \(1\). Its continuity points form a dense \(G_\delta\) subset of \(I\).
- At every continuity point of \(f^{\sd}\), the classical derivative exists and \(f'=f^{\sd}\).
- If \(|f^{\sd}|\leq M\) throughout \(I\), then \(|f(y)-f(x)|\leq M|y-x|\) for all \(x,y\in I\). Thus \(f\) is Lipschitz continuous and \(f'=f^{\sd}\) almost everywhere.
- If \(f^{\sd}\) is continuous throughout \(I\), then \(f\in C^1(I)\) and \(f'=f^{\sd}\) everywhere.
These results make continuity a substantive hypothesis, rather than an automatic consequence of the generalized derivative.
The second-order derivative is defined by \(f^{\sd\sd}=(f^{\sd})^{\sd}\). Let \(S^1(I)\) consist of continuous specularly differentiable functions, and let \(S^2(I)\) consist of those \(f\in S^1(I)\) for which \(f^{\sd}\in S^1(I)\). Then
The definition of \(S^2\) requires continuity of both \(f\) and \(f^{\sd}\). Merely taking the specular derivative twice does not ensure classical differentiability, even for continuous functions.
For a simple example in \(S^2\) but outside \(C^2\), take \(f(x)=\frac12x|x|\). Then \(f^{\sd}(x)=|x|\) and \(f^{\sd\sd}(x)=\operatorname{sgn}(x)\), with \(\operatorname{sgn}(0)=0\). The second specular derivative exists at the origin, where the classical second derivative does not.
The regular theory gives a complementary result: if both \(f\) and \(f^{\sd}\) are regularly specularly differentiable throughout \(I\), then \(f\in C^1(I)\) and \(f'=f^{\sd}\). In this case, the regular differentiability of \(f^{\sd}\) supplies the continuity required above.
Integration
The regular theory also relates differentiation to integration. Here piecewise continuity means continuity except at finitely many interior points, with finite one-sided limits at each of those points and one-sided continuity at the endpoints. For such a function \(g:[a,b]\to\mathbb{R}\), define
At every interior point, its regular specular derivative is the angular mean of the one-sided limits of \(g\):
This recovers \(g(x)\) at every continuity point. At a jump, the assigned value \(g(x)\) must equal this angular mean for the same identity to hold.
Conversely, if \(F\) is regularly specularly differentiable on \([a,b]\) and \(F^{\sd}\) is Riemann integrable, then
Here regular differentiability on the closed interval includes finite inward one-sided derivatives at the endpoints, which define \(F^{\sd}(a)\) and \(F^{\sd}(b)\).
Higher dimension
Paper
[3] K. Jung. Specular differentiation in normed vector spaces: Quasi-Mean Value and Quasi-Fermat Theorems. arXiv preprint arXiv:2601.10950v4, 2026.
The normed-space theory extends specular differentiation from a scalar variable to directions in a vector space. It distinguishes three levels: a derivative along one direction, a continuous linear operator representing all directional derivatives, and a uniform approximation as the increment approaches zero from arbitrary directions. The discussion below focuses on real-valued functions; the paper also defines specular differentiation for maps between normed vector spaces.
Specular directional derivatives
Let \(X\) be a real normed vector space, let \(\Omega\subset X\) be open, and let \(f:\Omega\to\mathbb R\). The norm measures the length of a direction and is part of the definition. The corresponding product norm on the graph space is
For \(x\in\Omega\), a nonzero direction \(v\in X\), and sufficiently small \(h>0\), define the slopes per unit distance by
Using the angular mean \(\mathcal C\) from the one-dimensional definition, the specular directional derivative is
This definition requires the displayed limit to exist as a finite real number. The derivative in the zero direction is defined to be zero. If the classical directional derivative exists, the specular directional derivative agrees with it. As in one dimension, the angular-mean limit can exist even when the individual slopes do not converge.
When the one-sided directional derivatives
are finite, the formula becomes
The factors \(\|v\|\) are essential. For the normalized line restriction
the exact relation is
For a unit direction, this is simply the specular derivative of \(t\mapsto f(x+tv)\). For a general direction, omitting the normalization changes the angular mean. This relation follows directly from the definition and does not require a general chain rule.
Gâteaux and Fréchet differentiability
Directional derivatives describe one line at a time. To obtain a differential, they must fit together into a continuous linear map. Write \(X^*\) for the space of continuous linear functionals on \(X\).
The function \(f\) is specularly Gâteaux differentiable at \(x\) if every specular directional derivative exists and there is an \(\ell\in X^*\) such that
This operator is unique and is denoted by \(\sGd f(x)\). The existence of directional derivatives alone does not establish their linearity, and specular Gâteaux differentiability alone does not imply continuity of \(f\).
The stronger specular Fréchet differentiability condition requires an \(\ell\in X^*\) satisfying
Here the limit covers all small increments \(w\), rather than holding a direction fixed first. The resulting operator is also unique and is written \(\widehat Df(x)\). It satisfies
Classical Fréchet differentiability implies specular Fréchet differentiability with the same differential; classical Gâteaux differentiability likewise implies specular Gâteaux differentiability with the same operator. Specular Fréchet differentiability implies specular Gâteaux differentiability.
For a basic nonsmooth example, consider \(f(x)=\|x\|\) on any nonzero real normed space. At the origin, the two normalized slopes in the Fréchet definition are \(1\) and \(-1\). Since \(\mathcal C(1,-1)=0\), the condition holds with
Thus the norm has a specular Fréchet differential at the origin even though it has no classical Fréchet differential there.
Quasi-Mean Value and Quasi-Fermat theorems
The Quasi-Mean Value Theorem bounds a finite change in the function using specular derivatives along the connecting segment. Assume that \(\Omega\) is open and convex, that \(f\) is continuous and specularly Gâteaux differentiable throughout \(\Omega\), and that both one-sided directional derivatives exist as extended real numbers at every point in every direction. They must not both equal \(+\infty\) or both equal \(-\infty\).
For distinct \(a,b\in\Omega\), put \(w=b-a\) and define the line restriction \(F(t)=f(a+tw)\) for \(t\in[0,1]\). Then
where the directional form of the line derivative is
The derivative acts on the scaled function \(\|w\|f\). The two bounds replace the single equality in the classical Mean Value Theorem; they need not be attained at the same point.
The Quasi-Fermat Theorem gives a necessary condition at an extremum. If \(\Omega\) is open, \(f\) is specularly Gâteaux differentiable in \(\Omega\), and \(x^*\in\Omega\) is a local minimizer or maximizer, then
Equivalently, the operator norm of \(\sGd f(x^*)\) is at most \(1\). The derivative can be nonzero at an extremum: already in one dimension, \(f(t)=t-2|t|\) has a maximum at \(0\) but
Gradients and convex functions
In a real Hilbert space \(H\), a specular Fréchet differential has a unique representing vector, the specular gradient \(\sg f(x)\), satisfying
In Euclidean space, its components are the specular partial derivatives:
where \(e_1,\ldots,e_n\) are the standard basis vectors. This identification assumes the specular Fréchet differential exists. A vector assembled from coordinate derivatives alone need not represent every directional derivative.
For example, \(f(x_1,x_2)=\max\{x_1,x_2\}\) has
The diagonal value differs from \(2(\sqrt2-1)\), so these directional derivatives cannot come from a single linear operator. This function has specular coordinate derivatives at the origin, but no specular Gâteaux or Fréchet differential there.
For a function that may take the value \(+\infty\), its effective domain is \(\operatorname{dom}f=\{x:f(x)<+\infty\}\). Such a function is proper if this domain is nonempty. At a point where \(f(x)\) is finite, the Fréchet subdifferential \(\widehat\partial f(x)\) consists of the functionals \(\ell\in X^*\) satisfying
Now suppose \(f:X\to\mathbb R\cup\{+\infty\}\) is proper, convex, and lower semicontinuous. If it is specularly Fréchet differentiable at an interior point \(x\) of its effective domain, then
On a reflexive Banach space, the differential also belongs to the convex subdifferential \(\partial f(x)\). In particular, in \(\mathbb R^n\) the specular gradient then satisfies the supporting-hyperplane inequality
This connects specular differentiation with convex optimization while retaining the differentiability assumptions needed for a single gradient to represent all directions.
Relation to the package
The package evaluates finite-difference approximations to these quantities. For scalar-valued functions, specular.derivative combines the two sampled quotients through \(\mathcal C\), while specular.gradient assembles the corresponding coordinate values. specular.jacobian applies this coordinate construction to each scalar output component. These computations do not by themselves establish the existence of a Gâteaux or Fréchet differential.
The function specular.scaled_mean also exposes the rescaled angular mean
The unscaled mean corresponds to \(\sigma=1\). See Calculation for numerical evaluation and Optimization for the SPEG iteration.
References
One dimension
[1] K. Jung. Specular differentiation in one dimension: a quasi-mean value theorem, regularity, and discontinuities. arXiv preprint arXiv:2601.09900v5, 2026.
[2] K. Jung and J. Oh. Regular specular differentiation in Euclidean spaces. arXiv preprint arXiv:2210.06062v3, 2022.
Higher dimensions
[3] K. Jung. Specular differentiation in normed vector spaces: Quasi-Mean Value and Quasi-Fermat Theorems. arXiv preprint arXiv:2601.10950v4, 2026.
Applications
[4] K. Jung. The specular ellipse method for scalar ordinary differential equations: exactness and accuracy up to fourth order. arXiv preprint arXiv:2608.30280, 2026.
[5] K. Jung and J. Oh. Nonsmooth convex optimization using the specular gradient method with root-linear convergence. arXiv preprint arXiv:2412.20747v3, 2024.
[6] K. Jung. Specular gradient methods for nonsmooth convex optimization in Euclidean spaces: a subgradient selection strategy. arXiv preprint arXiv:2605.25490, 2026.