Metadata-Version: 2.4
Name: diffstep
Version: 1.3.0
Summary: A symbolic differentiation library.
Home-page: https://campus.cs.le.ac.uk/gitlab/ug_project/25-26/aoe8
Author: Ayo
Author-email: Ayo <akoitilo@gmail.com>
License: Copyright 2025 Ayo Emmanuel
        
        Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE.txt
Dynamic: author
Dynamic: home-page
Dynamic: license-file

# 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:

```bash
pip install diffstep
```

## Quick Start

### Basic Access (`from diffstep import diffstep`)

```python
from diffstep import diffstep

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

### Advanced Access (`import diffstep`)

```python
import diffstep

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

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

diffstep.parse_expression("sin(x) + cos(x)")
# Prints a readable AST tree
```

## 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.

- `parse_expression(expression: str, pretty: bool | None = None)`
  Parses an expression to AST form. By default, it prints a pretty ASCII tree.
  Pass `pretty=False` to return the raw AST node instead.

- `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.
