Skip to main content

∇ py-nabla: Mathematics in the language of thought.

PyPI version License: MIT Python 3.9+ Build Status Documentation

py-nabla is a production-grade mathematical computing engine that bridges the gap between LaTeX notation and Python execution. Write math exactly as you think it; execute it with the power of SymPy and NumPy.


🔥 Why py-nabla?

Translating complex LaTeX equations into nested Python code is brittle, time-consuming, and error-prone. One misplaced parenthesis in a symbolic expression can lead to hours of debugging.

py-nabla eliminates this friction.

  • Parse Naturally: High-fidelity Earley parser for complex LaTeX (vmatrix, cases, summations, mixed partials).
  • Compute Symbolically: Full integration with SymPy for calculus, algebra, and simplification.
  • Execute Numerically: Instant vectorization via NumPy for high-performance evaluation.
  • Visualize Beautifully: Built-in 2D/3D plotting engine with publication-ready aesthetics.
  • Render Professionally: Bidirectional LaTeX conversion with support for Leibniz, Prime, and Newton (dot) notations.

🛠️ Installation

# Core engine
pip install py-nabla

# With plotting support (recommended)
pip install py-nabla[plotting]

# Install all development dependencies
pip install py-nabla[all]

✨ Quickstart: The "Wow" Moment

Differentiate a complex expression, simplify it, and plot it in seconds:

import py_nabla as nb
import numpy as np

# 1. Parse your LaTeX
f = nb.parse(r"\frac{d}{dx} \left( x^2 \sin(x) \right)")

# 2. Compute analytically
print(f"Derivative: {f.simplify()}") 
# Result: 2*x*sin(x) + x**2*cos(x)

# 3. Render back to LaTeX (Leibniz style)
print(f.latex(mode='display'))

# 4. Solve Differential Equations (v1.1.0+)
# Solve y'' + y = 0 natively
eq = nb.parse(r"y'' + y = 0")
print(f"Solution: {eq.dsolve()}") # y(t) = C1*sin(t) + C2*cos(t)

# 5. Plot instantly
nb.plot(f, domain=(-2, 2), title="Differentiated Waveform")

💎 Production Features (v1.1.0)

🧠 Advanced Parser

  • Calculus: Support for $\int, \iint, \oint$, $\lim_{x \to a}$, $\sum, \prod$, and partial derivatives.
  • Differential/Integral Equations: Solve ODEs, IDEs, and Fractional Differential Equations (FDEs) using dsolve() with a built-in Laplace Transform engine. Supports Newton's prime notation ($y', y''$) and fractional orders ($y^{(0.5)}$) natively.
  • Linear Algebra: Matrix environments (bmatrix, pmatrix, vmatrix) and vector notations.
  • Piecewise: Support for \begin{cases} environments.
  • Ambiguity Resolution: Intelligent splitting of multi-char symbols (e.g., 2weight $\to 2 \cdot w \cdot e \cdot i \cdot g \cdot h \cdot t$).

🪄 Publication Rendering

Beautiful bidirectional conversion with custom styles:

  • Derivative Styles: Choose between leibniz ($\frac{dy}{dx}$), prime ($y'$), or dot ($\dot{y}$).
  • Multiple Modes: inline, display, equation, or align.

📊 Plotting Engine

  • 2D Plots: Multi-function plotting with automatic labeling.
  • 3D Plots: Surface, wireframe, and contour plots for multivariable functions.
  • Parametric: Plot complex curves like circles, spirals, or Lissajous figures.

📚 Documentation & Tutorials


🤝 Contributing

We welcome contributions from the mathematical and open-source communities! Please see CONTRIBUTING.md for guidelines, and our Testing Guide before submitting code.

📄 License

py-nabla is released under the MIT License.

Metadata

Release files for py-nabla 1.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for py-nabla 1.1.0
File Size Uploaded
py_nabla-1.1.0.tar.gz 31.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for py-nabla 1.1.0
File Interpreter ABI Platform
py_nabla-1.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 63.4 kB

Release files / py_nabla-1.1.0.tar.gz

Download URL py_nabla-1.1.0.tar.gz
Size 31.9 kB
Tags Source
SHA-256 checksum
How to use checksums
f91d52467af58b5be98556bcbcbdf5fa8a09cad2ee928e3ca56ad5a3de653d5f
BLAKE2b-256 checksum
How to use checksums
9e8ffd3071fcfc1d54dd97667c011bda8cc8dd95faccd53ca32b26e44af80bf4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.4

Release files / py_nabla-1.1.0-py3-none-any.whl

Download URL py_nabla-1.1.0-py3-none-any.whl
Size 31.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0f495594444e55ed53551b53d5373b15845cb153c5af4bd050e7ab97752daa2b
BLAKE2b-256 checksum
How to use checksums
67b42c238631a009210fb52863329332ec39ec5dab9757424df0e156ca5483a1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.4

Release history Release notifications | RSS feed

This release

1.1.0 This release

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page