complex-expr-parser

A fault-tolerant parser for complex-valued mathematical functions with human-friendly notation support.

Features

  • Human-friendly syntax: Accepts natural mathematical notation

  • Implicit multiplication: 2z becomes 2*z

  • Power notation: z^2 becomes z**2

  • Absolute value: |z| becomes Abs(z)

  • Conjugate shorthand: z* becomes conjugate(z)

  • Unicode support: pi, sqrt, oo (infinity)

  • Function aliases: ln -> log, arcsin -> asin, etc.

  • Special functions: Gamma, Zeta, and more via mpmath

  • Vectorized evaluation: Works with NumPy arrays for fast computation

Quick Example

from complex_expr_parser import parse_complex_function, get_callable

# Parse an expression
expr = parse_complex_function("z^2 + 2z + 1")
print(expr)  # z**2 + 2*z + 1

# Get a callable function
f = get_callable("sin(z)/z")
print(f(1+1j))

Installation

pip install complex-expr-parser

# With optional dependencies
pip install complex-expr-parser[all]

Indices and tables