Skip to content

chebpy/chebpy

Repository files navigation

ChebPy

A Python implementation of Chebfun

License: BSD-3-Clause Python versions PyPI - Version

Github Linux MAC OS Code style: ruff uv Hatch project CodeFactor

CI PRE-COMMIT DEPTRY MARIMO DEVCONTAINER

Open in GitHub Codespaces

๐Ÿ”ฌ Numerical computing with Chebyshev series approximations

Symbolic-numeric computation with functions

ChebPy is a Python implementation of Chebfun, bringing the power of Chebyshev polynomial approximations to Python. It allows you to work with functions as first-class objects, performing operations like differentiation, integration, and root-finding with machine precision accuracy.

Table of Contents


โœจ Features

Work with functions as easily as numbers

  • ๐Ÿ”ข Function Approximation: Automatic Chebyshev polynomial approximation of smooth functions
  • ๐Ÿ“ Calculus Operations: Differentiation, integration, and root-finding with machine precision
  • ๐Ÿ“Š Plotting: Beautiful function visualizations with matplotlib integration
  • ๐Ÿงฎ Arithmetic: Add, subtract, multiply, and compose functions naturally
  • ๐ŸŽฏ Adaptive: Automatically determines optimal polynomial degree for given tolerance
  • ๐Ÿ”— Interoperability: Works seamlessly with NumPy and SciPy ecosystems

๐Ÿ“ฅ Installation

Using pip (recommended)

pip install chebpy

From source (development)

git clone https://github.com/chebpy/chebpy.git
cd chebpy
pip install -e .

Note: Use -e flag for editable installation during development

๐Ÿ› ๏ธ Development

For contributors and advanced users

ChebPy uses modern Python development tools for a smooth developer experience:

# ๐Ÿ“ฆ Install development dependencies
make install

# ๐Ÿงช Run tests with coverage
make test

# โœจ Format and lint code
make fmt
make lint

# ๐Ÿ““ Start interactive notebooks
make marimo

# ๐Ÿ” View test coverage report
make coverage

Development Tools

  • Testing: pytest with coverage reporting
  • Formatting: ruff for code formatting and linting
  • Notebooks: marimo for interactive development
  • Task Management: Taskfile for build automation

Quick Start

ChebPy Example

This figure was generated with the following simple ChebPy code:

import numpy as np
from chebpy import chebfun

# Create functions as chebfuns on interval [0, 10]
f = chebfun(lambda x: np.sin(x**2) + np.sin(x)**2, [0, 10])
g = chebfun(lambda x: np.exp(-(x-5)**2/10), [0, 10])

# Find intersection points
roots = (f - g).roots()

# Plot both functions and mark intersections
ax = f.plot(label='f(x) = sin(xยฒ) + sinยฒ(x)')
g.plot(ax=ax, label='g(x) = exp(-(x-5)ยฒ/10)')
ax.plot(roots, f(roots), 'ro', markersize=8, label='Intersections')
ax.legend()
ax.grid(True, alpha=0.3)

More Examples

# Differentiation and integration
f = chebfun(lambda x: np.exp(x) * np.sin(x), [-1, 1])
df_dx = f.diff()          # Derivative
integral = f.sum()        # Definite integral

# Root finding
g = chebfun(lambda x: x**3 - 2*x - 5, [-3, 3])
roots = g.roots()         # All roots in the domain

# Function composition
# h = f + g                 # Addition
# product = f * g           # Multiplication


Documentation


๐Ÿ“„ License

ChebPy is licensed under the 3-Clause BSD License.

๐Ÿ“œ See the full license in the LICENSE.rst file.


๐Ÿ‘ฅ Contributing

We welcome contributions! ๐ŸŽ‰

Whether you're fixing bugs, adding features, or improving documentation, your help makes ChebPy better for everyone.

Quick Start for Contributors

  1. ๐Ÿด Fork the repository
  2. ๐ŸŒฟ Create your feature branch
    git checkout -b feature/amazing-feature
  3. โœจ Make your changes and add tests
  4. ๐Ÿงช Test your changes
    make test
  5. ๐Ÿ“ Commit your changes
    git commit -m 'Add amazing feature'
  6. ๐Ÿš€ Push to your branch
    git push origin feature/amazing-feature
  7. ๐ŸŽฏ Open a Pull Request

Resources

Acknowledgments ๐Ÿ™


Made with โค๏ธ by the ChebPy community

โญ If you find ChebPy useful, please consider giving it a star! โญ

About

A Python implementation of Chebfun

Resources

License

Code of conduct

Contributing

Stars

Watchers

Forks

Contributors 11