amari-calculus
Geometric calculus - a unified framework for differential and integral calculus using geometric algebra.
Overview
amari-calculus provides geometric calculus operations that unify vector calculus, differential forms, and tensor calculus into a single coherent framework. The key insight is that the vector derivative operator ∇ combines the familiar gradient, divergence, and curl operations into one fundamental operation.
Features
- Vector Derivative Operator: The fundamental ∇ operator
- Classical Operators: Gradient, divergence, curl, Laplacian
- Field Types: Scalar, vector, and multivector fields
- Coordinate Systems: Cartesian, spherical, cylindrical, polar
- Manifold Calculus: Covariant derivatives, connections
- Lie Derivatives: Derivatives along vector fields
- Integration: Manifold integration via amari-measure
Installation
Add to your Cargo.toml:
[]
= "0.12"
Feature Flags
[]
# Default features
= "0.12"
# Minimal, no-std compatible
= { = "0.12", = false }
Quick Start
Gradient of a Scalar Field
use ;
// Define scalar field f(x, y, z) = x² + y²
let f = new;
// Create vector derivative operator
let nabla = new;
// Compute gradient at point (1, 2, 0)
let grad_f = nabla.gradient;
// Gradient is approximately (2, 4, 0)
Divergence of a Vector Field
use ;
// Define vector field F(x, y, z) = (x, y, z)
let f = new;
let nabla = new;
// Compute divergence (should be 3)
let div_f = nabla.divergence;
Curl of a Vector Field
use ;
// Define vector field F(x, y, z) = (-y, x, 0) (rotation around z-axis)
let f = new;
let nabla = new;
// Compute curl (returns bivector representing rotation)
let curl_f = nabla.curl;
// Curl is (0, 0, 2) as a bivector
Mathematical Foundation
The Vector Derivative
The vector derivative operator is defined as:
∇ = eⁱ ∂ᵢ (sum over basis vectors)
This operator combines:
- Dot product → divergence: ∇·F
- Wedge product → curl: ∇∧F
- Full geometric product → complete derivative: ∇F = ∇·F + ∇∧F
Unification of Calculus
| Classical | Differential Forms | Geometric Calculus |
|---|---|---|
| grad f | df | ∇f |
| div F | ⋆d⋆F | ∇·F |
| curl F | ⋆dF | ∇∧F |
| ∇²f | ⋆d⋆df | ∇²f = ∇·∇f |
The Fundamental Theorem
Geometric calculus has a single fundamental theorem that unifies all integral theorems:
∫_V (∇F) dV = ∮_∂V F dS
This single equation encompasses:
- Gradient theorem (fundamental theorem of calculus)
- Divergence theorem (Gauss's theorem)
- Stokes' theorem
- Green's theorem
Key Types
ScalarField<P, Q, R>
Scalar-valued functions on Cl(P,Q,R) space:
use ScalarField;
// Temperature field T(x, y, z)
let temperature = new;
VectorField<P, Q, R>
Vector-valued functions:
use ;
// Velocity field
let velocity = new;
MultivectorField<P, Q, R>
General multivector-valued functions:
use MultivectorField;
// Electromagnetic field (bivector field)
let em_field = new;
VectorDerivative<P, Q, R>
The ∇ operator:
use ;
// Create in Cartesian coordinates
let nabla = new;
// Or in spherical coordinates
let nabla_sph = new;
Coordinate Systems
| System | Coordinates | Use Case |
|---|---|---|
| Cartesian | (x, y, z) | General computations |
| Spherical | (r, θ, φ) | Central potentials |
| Cylindrical | (ρ, φ, z) | Axial symmetry |
| Polar | (r, θ) | 2D problems |
Modules
| Module | Description |
|---|---|
fields |
ScalarField, VectorField, MultivectorField |
operators |
gradient, divergence, curl, laplacian |
derivative |
VectorDerivative operator |
manifold |
RiemannianManifold, covariant derivatives |
lie |
Lie derivatives along vector fields |
integration |
ManifoldIntegrator |
Applications
Electromagnetism
use *;
// Electric field E = -∇φ
let potential = new;
let nabla = new;
let e_field = nabla.gradient;
Fluid Dynamics
use *;
// Velocity field
let velocity = new;
let nabla = new;
// Incompressibility: ∇·v = 0
let div_v = nabla.divergence;
// Vorticity: ω = ∇∧v
let vorticity = nabla.curl;
Heat Equation
use *;
// Temperature field
let temp = new;
let nabla = new;
// Laplacian for heat diffusion
let laplacian_t = laplacian;
Prelude
For convenient imports:
use *;
// Imports: ScalarField, VectorField, MultivectorField,
// VectorDerivative, CoordinateSystem,
// gradient, divergence, curl, laplacian
License
Licensed under either of Apache License, Version 2.0 or MIT License at your option.
Part of Amari
This crate is part of the Amari mathematical computing library.