Specular differentiation in normed vector spaces and its applications
Project description
Specular Differentiation
The Python package specular implements specular differentiation which generalizes classical differentiation.
This implementation strictly follows the definitions, notations, and results in [1] and [2].
A specular derivative (the red line) can be understood as the average of the inclination angles of the right and left derivatives. In contrast, a symmetric derivative (the purple line) is the average of the right and left derivatives. Their difference is illustrated as in the following figure.
Table of Contents
Installation
Requirements
specular-differentiation requires:
- Python >= 3.11
ipython>= 8.12.3matplotlib>= 3.10.8numpy>= 2.4.0pandas>= 2.3.3tqdm>= 4.67.1
User installation
Standard Installation (NumPy backend)
pip install specular-differentiation
Advanced Installation (JAX backend)
pip install "specular-differentiation[jax]"
See the documentation for advanced installation (JAX backend, Pytest).
Quick start
The following simple example calculates the specular derivative of the ReLU function $f(x) = max(0, x)$ at the origin.
import specular
ReLU = lambda x: max(x, 0)
print(specular.derivative(ReLU, x=0))
0.41421356237309515
Applications
Specular differentiation is defined in normed vector spaces, allowing for applications in higher-dimensional Euclidean spaces.
The specular package includes the following applications.
Ordinary differential equation
In [1], seven schemes are proposed for solving ODEs numerically:
- the specular Euler scheme of Type 1~6
- the specular trigonometric scheme
The following example shows that the specular Euler schemes of Type 5 and 6 yield more accurate numerical solutions than classical schemes: the explicit and implicit Euler schemes and the Crank-Nicolson scheme.
Optimization
In [2], three methods are proposed for optimizing nonsmooth convex objective functions:
- the specular gradient (SPEG) method
- the stochastic specular gradient (S-SPEG) method
- the hybrid specular gradient (H-SPEG) method
The following example compares the three proposed methods with the classical methods: gradient descent (GD), Adaptive Moment Estimation (Adam), and Broyden-Fletcher-Goldfarb-Shanno (BFGS).
Documentation
Getting Started
API Reference
Examples
LaTeX macro
To use the specular differentiation symbol in your LaTeX document, add the following code to your preamble (before \begin{document}):
% Required packages
\usepackage{graphicx}
\usepackage{bm}
% Definition of Specular Differentiation symbol
\newcommand\sd[1][.5]{\mathbin{\vcenter{\hbox{\scalebox{#1}{\,$\bm{\wedge}$}}}}}
Usage examples
Use the symbol in your document (after \begin{document}):
% A specular derivative in the one-dimensional Euclidean space
$f^{\sd}(x)$
% A specular directional derivative in normed vector spaces
$\partial^{\sd}_v f(x)$
Citing specular-differentiation
To cite this repository:
@software{Jung_specular-differentiation_2026,
author = {Jung, Kiyuob},
doi = {10.5281/zenodo.18246734},
license = {MIT},
month = jan,
title = {{specular-differentiation}},
url = {https://github.com/kyjung2357/specular-differentiation},
version = {1.0.0},
year = {2026},
}
References
[1] K. Jung. Nonlinear numerical schemes using specular differentiation for initial value problems of first-order ordinary differential equations. arXiv preprint arXiv:2601.09900, 2026.
[2] K. Jung. Specular differentiation in normed vector spaces and its applications to nonsmooth convex optimization. arXiv preprint arXiv:2601.10950, 2026.
[3] K. Jung and J. Oh. The specular derivative. arXiv preprint arXiv:2210.06062, 2022.
[4] K. Jung and J. Oh. The wave equation with specular derivatives. arXiv preprint arXiv:2210.06933, 2022.
[5] K. Jung and J. Oh. Nonsmooth convex optimization using the specular gradient method with root-linear convergence. arXiv preprint arXiv:2210.06933, 2024.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file specular_differentiation-1.0.8.tar.gz.
File metadata
- Download URL: specular_differentiation-1.0.8.tar.gz
- Upload date:
- Size: 24.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0173bc40ef3f95ea9424a3445701cf90b48561a3536023e8c119af4d952971b8
|
|
| MD5 |
1fdbe11750676535738489dac721f7a7
|
|
| BLAKE2b-256 |
0b87f5bcbdd48ac399853f24f319f8f30e8e9b25afac109d325e375c2c95f57e
|
File details
Details for the file specular_differentiation-1.0.8-py3-none-any.whl.
File metadata
- Download URL: specular_differentiation-1.0.8-py3-none-any.whl
- Upload date:
- Size: 24.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0c16c8fafb91263614d1fbe4a741440459935c3b5f63b37ea05a8fcf522de05d
|
|
| MD5 |
62b5c3035910f817423ab029345b5711
|
|
| BLAKE2b-256 |
8cbc45c09c5699a16d1f9dce0ebf68b54aa3ff4a26c2289f296b3e8b3948f6fe
|