Skip to main content

A symbolic differentiation library.

Project description

diffstep

diffstep is a lightweight Python library for algorithmic differentiation.

It lets you:

  • Differentiate expressions like x^2 + 3x + 2
  • Evaluate gradients at specific points

Installation

Install from PyPI:

pip install diffstep

Quick Start

Basic Access (from diffstep import diffstep)

from diffstep import diffstep

diffstep("x^2 + 3x + 2")
# 2*x + 3

Advanced Access (import diffstep)

import diffstep

diffstep.differentiate("x^2 + 3x + 2")
# 2*x + 3

diffstep.gradient("x^2 + 3x + 2", 1)
# 5

Public API

  • diffstep(expression: str) Main entry point. Returns the simplified symbolic derivative.

  • differentiate(expression: str) Alias of diffstep().

  • gradient(expression: str, x_value: float) Evaluates the derivative at a specific x value.

  • normalise_expression(expression: str) Returns the normalized expression string used internally by the parser.

  • DiffStep(expression: str) Deprecated alias for backward compatibility.

Supported Expression Features

  • Variables: x
  • Constants and arithmetic: +, -, *, /, ^
  • Common functions such as sin, cosec, arctan, ln, and sqrt

Project Structure

  • diffstep/core/: validation, tokenization, parsing, AST nodes
  • diffstep/differentiation/: differentiation rules
  • diffstep/simplify/: simplification logic
  • diffstep/printer/: AST-to-expression string conversion
  • diffstep/pipeline.py: user-facing workflow functions

License

MIT License. See LICENSE.txt for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

diffstep-1.2.0.tar.gz (10.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

diffstep-1.2.0-py3-none-any.whl (10.5 kB view details)

Uploaded Python 3

File details

Details for the file diffstep-1.2.0.tar.gz.

File metadata

  • Download URL: diffstep-1.2.0.tar.gz
  • Upload date:
  • Size: 10.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.8

File hashes

Hashes for diffstep-1.2.0.tar.gz
Algorithm Hash digest
SHA256 a02d38c2824497cbf4c16ce7487b90e539899194e3c242a042d1bd2e2f0782b8
MD5 b107c5209ea5ab6e3bc2316a66e1eb52
BLAKE2b-256 3dda01329f75a2a66fe73b5b224b0bae0e275de62c2a91f43b015f43e7a27121

See more details on using hashes here.

File details

Details for the file diffstep-1.2.0-py3-none-any.whl.

File metadata

  • Download URL: diffstep-1.2.0-py3-none-any.whl
  • Upload date:
  • Size: 10.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.8

File hashes

Hashes for diffstep-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4c72af19b091b08fba08c158db3299ba610b21e299ff11fba31404c6c126b24f
MD5 e45a2c551f486682c59ef6a9f63e3ae7
BLAKE2b-256 ea74a5b3d56c508dd3176505d091658096c37e6114b9b0488147fed284d16d6f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page