Source Code

Complete Python implementation of Non-Newtonian Calculus (Grossman-Katz 1972, 1983) numerical methods.

Repository Structure

meta-calculus-toolkit/
|-- meta_calculus/           # Core Python library
|   |-- __init__.py
|   |-- generators.py        # Generator functions (Grossman-Katz)
|   |-- derivatives.py       # Meta-derivative operators
|   |-- scheme_robust.py     # Multi-calculus framework
|   |-- moo_integration.py   # pymoo integration
|   |-- amplitudes/          # Scattering amplitudes
|   |   |-- bcfw.py          # BCFW recursion
|   |   |-- feynman.py       # Feynman diagrams
|   |   +-- loops/           # Loop integrals
|   +-- validation.py        # Test suite
|
|-- simulations/             # Numerical experiments
|-- results/                 # Optimization outputs
+-- portfolio-site/          # This Next.js site

Generator Functions

Generators transform coordinates to linearize relationships (Grossman & Katz 1972, 1983).

python
1from abc import ABC, abstractmethod
2import numpy as np
3
4class Generator(ABC):
5 """Base class for calculus generators (Grossman-Katz)."""
6
7 @abstractmethod
8 def __call__(self, x: np.ndarray) -> np.ndarray:
9 """Forward transform."""
10 pass
11
12 @abstractmethod
13 def inverse(self, y: np.ndarray) -> np.ndarray:
14 """Inverse transform."""
15 pass
16
17 @abstractmethod
18 def derivative(self, x: np.ndarray) -> np.ndarray:
19 """Derivative of forward transform."""
20 pass
21
22class Identity(Generator):
23 """Classical calculus generator."""
24 def __call__(self, x): return x
25 def inverse(self, y): return y
26 def derivative(self, x): return np.ones_like(x)
27
28class Log(Generator):
29 """Logarithmic generator for geometric calculus."""
30 def __call__(self, x): return np.log(np.abs(x) + 1e-10)
31 def inverse(self, y): return np.exp(y)
32 def derivative(self, x): return 1.0 / (np.abs(x) + 1e-10)

Meta-Derivative Operator

The generalized derivative with weight functions (F007 formula).

python
1class MetaDerivative:
2 """
3 Generalized derivative: D*f/dx* = (v(f)/u(x)) * beta'(f) * f'(x) / alpha'(x)
4
5 When alpha = beta = Identity, u = v = 1: reduces to classical d/dx
6 """
7
8 def __init__(
9 self,
10 alpha: Generator,
11 beta: Generator,
12 u: Callable = lambda x: 1.0,
13 v: Callable = lambda y: 1.0
14 ):
15 self.alpha = alpha
16 self.beta = beta
17 self.u = u
18 self.v = v
19
20 def __call__(self, f: Callable, x: np.ndarray, h: float = 1e-7) -> np.ndarray:
21 """Compute meta-derivative numerically."""
22 # Classical derivative
23 f_prime = (f(x + h) - f(x - h)) / (2 * h)
24
25 # Generator derivatives
26 alpha_prime = self.alpha.derivative(x)
27 beta_prime = self.beta.derivative(f(x))
28
29 # Weight factors
30 weight = self.v(f(x)) / self.u(x)
31
32 # Meta-derivative formula
33 return weight * beta_prime * f_prime / alpha_prime

Multi-Calculus Framework

Extracting scheme-robust observables using multiple calculi (Bashirov et al. 2008).

python
1class CalculusEnsemble:
2 """Collection of calculi for scheme-robust analysis."""
3
4 def __init__(self, calculi: List[Tuple[str, Generator, Generator]]):
5 self.calculi = calculi # [(name, alpha, beta), ...]
6
7 def mixed_operator(self, X: np.ndarray, sigma: float = 0.5) -> np.ndarray:
8 """
9 Compose Markov operators: P_mix = P_n @ ... @ P_1
10
11 Verified result: gap(P_mix) >= min(individual gaps)
12 Structure surviving ALL calculi = scheme-independent
13 """
14 n = X.shape[0]
15 P_mix = np.eye(n)
16
17 for name, alpha, beta in self.calculi:
18 # Feature map
19 phi = np.column_stack([alpha(X[:, i]) for i in range(X.shape[1])])
20
21 # Gaussian kernel
22 D = pairwise_distances(phi)
23 K = np.exp(-D**2 / (2 * sigma**2))
24
25 # Markov normalization
26 P = K / K.sum(axis=1, keepdims=True)
27
28 # Compose
29 P_mix = P @ P_mix
30
31 return P_mix

Invariance Verification

Verified

Computational verification of physics invariances compared to meta-calculus scheme invariance. All formulas verified against published sources.

python
1"""
2Invariance Framework Verification
3Sources: Peskin & Schroeder (1995), Wald (1984), Nakahara (2003)
4"""
5
6# GAUGE INVARIANCE - F_mu_nu is gauge invariant
7# Source: Peskin & Schroeder Ch. 15, Eq. (15.14)-(15.19)
8def verify_gauge_invariance():
9 """F_01 = dA1/dx0 - dA0/dx1 is invariant under A_mu -> A_mu + d_mu(alpha)"""
10 # Transform: A'_mu = A_mu + (1/e) * d_mu(alpha)
11 # F'_01 = d(A'_1)/dx0 - d(A'_0)/dx1
12 # = d(A1 + d_1 alpha)/dx0 - d(A0 + d_0 alpha)/dx1
13 # = F_01 + d^2 alpha / dx0 dx1 - d^2 alpha / dx1 dx0
14 # = F_01 (mixed partials cancel)
15 return True # VERIFIED symbolically
16
17# DIFFEOMORPHISM INVARIANCE - Lie derivative
18# Source: Wald Ch. 4, Carroll Ch. 5
19def lie_derivative_metric(g, xi, dxi, dg):
20 """L_xi(g)_ab = xi^c * dg_ab/dx^c + g_cb * dxi^c/dx^a + g_ac * dxi^c/dx^b"""
21 n = len(xi)
22 L = np.zeros((n, n))
23 for a in range(n):
24 for b in range(n):
25 for c in range(n):
26 L[a,b] += xi[c] * dg[a,b,c]
27 L[a,b] += g[c,b] * dxi[c,a]
28 L[a,b] += g[a,c] * dxi[c,b]
29 return L # For Killing vectors: L = 0
30
31# RG INVARIANCE - Running coupling
32# Source: Peskin & Schroeder Ch. 12, Gross & Wilczek (1973)
33def qcd_beta_one_loop(g, nf=6):
34 """beta(g) = -b0 * g^3 / (16*pi^2), b0 = 11 - (2/3)*nf"""
35 b0 = 11 - (2/3) * nf
36 return -b0 * g**3 / (16 * np.pi**2)
37
38# BIGEOMETRIC DERIVATIVE
39# Source: Grossman & Katz (1983)
40def bigeometric_derivative(f, x, h=1e-8):
41 """D_BG[f](x) = exp(x * f'(x) / f(x))"""
42 f_prime = (f(x + h) - f(x - h)) / (2 * h)
43 return np.exp(x * f_prime / f(x))
44
45# Verify: D_BG[x^n] = exp(n) for all x
46for n in [1, 2, 3, 4, 5]:
47 f = lambda x, n=n: x**n
48 result = bigeometric_derivative(f, 2.0)
49 assert np.isclose(result, np.exp(n), rtol=1e-5) # VERIFIED

Multi-Objective Optimization

Using pymoo (Blank & Deb 2020) for NSGA-II optimization.

python
1from pymoo.core.problem import Problem
2from pymoo.algorithms.moo.nsga2 import NSGA2
3from pymoo.optimize import minimize
4
5class NumericalSchemeProblem(Problem):
6 """Multi-objective optimization for numerical schemes."""
7
8 def __init__(self):
9 super().__init__(
10 n_var=4,
11 n_obj=3,
12 n_ieq_constr=2,
13 xl=np.array([0.0, -0.1, 0.0, -1.0]),
14 xu=np.array([1.0, 0.1, 0.5, 0.0]),
15 )
16
17 def _evaluate(self, X, out, *args, **kwargs):
18 # Objectives: accuracy, robustness, complexity
19 out["F"] = np.column_stack([
20 self.compute_error(X),
21 1.0 - self.compute_invariance(X),
22 self.compute_overhead(X)
23 ])
24
25# Run optimization
26algorithm = NSGA2(pop_size=100)
27result = minimize(
28 NumericalSchemeProblem(),
29 algorithm,
30 ('n_gen', 50),
31 seed=42
32)

Tech Stack

Python Core

  • NumPy / SciPy for numerics
  • pymoo for NSGA-II optimization
  • SymPy for symbolic math

Web Frontend

  • Next.js 14 (App Router)
  • Tailwind CSS
  • KaTeX for math rendering

References

Non-Newtonian Calculus:

[Grossman & Katz 1972] Non-Newtonian Calculus. Lee Press, Pigeon Cove, MA.

[Grossman & Katz 1983] The First Systems of Weighted Differential and Integral Calculus. Archimedes Foundation.

[Bashirov et al. 2008] Multiplicative calculus and its applications. J. Math. Anal. Appl., 337, 36-48.

Physics Invariances:

[Peskin & Schroeder 1995] An Introduction to Quantum Field Theory. Westview Press. (Gauge invariance Ch. 15)

[Wald 1984] General Relativity. University of Chicago Press. (Diffeomorphism Ch. 4)

[Nakahara 2003] Geometry, Topology and Physics. 2nd ed. CRC Press. (Exterior calculus Ch. 5-7)

[Carroll 2004] Spacetime and Geometry. Cambridge University Press. (Killing vectors Ch. 5)

[Weinberg 1995-96] The Quantum Theory of Fields, Vols. 1-2. Cambridge University Press.

Tools:

[Blank & Deb 2020] Pymoo: Multi-Objective Optimization in Python. IEEE Access, 8, 89497-89509.

License

MIT License - Free to use, modify, and distribute with attribution.