Skip to main content

A Python implementation of Chebfun

Project description

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!

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

chebfun-0.6.0.tar.gz (645.5 kB view details)

Uploaded Source

Built Distribution

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

chebfun-0.6.0-py3-none-any.whl (63.9 kB view details)

Uploaded Python 3

File details

Details for the file chebfun-0.6.0.tar.gz.

File metadata

  • Download URL: chebfun-0.6.0.tar.gz
  • Upload date:
  • Size: 645.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for chebfun-0.6.0.tar.gz
Algorithm Hash digest
SHA256 40d59325e4eb49fb6baa7739d1757df2ac3850def1fcbc94b4a8cfc22eac9f07
MD5 dfe3bde9bef8e4ebb65d3d98da8ea925
BLAKE2b-256 b6968ee6ae9c7b6635be6b916166ea5d599e5410595cfd9aef5a451f2b22536f

See more details on using hashes here.

Provenance

The following attestation bundles were made for chebfun-0.6.0.tar.gz:

Publisher: rhiza_release.yml on chebpy/chebpy

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file chebfun-0.6.0-py3-none-any.whl.

File metadata

  • Download URL: chebfun-0.6.0-py3-none-any.whl
  • Upload date:
  • Size: 63.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for chebfun-0.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c467c8aad289ebb99f52d8699aea5c7d9386a9a1a2a2556e83ddda9e17c88104
MD5 3b954f21116b2fb5345107044f47ac67
BLAKE2b-256 f2118fcf67a936abe61bd7d21d305632097804046a52de77deef1387ba1ef4d2

See more details on using hashes here.

Provenance

The following attestation bundles were made for chebfun-0.6.0-py3-none-any.whl:

Publisher: rhiza_release.yml on chebpy/chebpy

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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