Skip to main content

Spectral Derivatives

Build Status Coverage Status

Documentation, How it works.

This repository is home to Python code that can take spectral derivatives with the Chebyshev basis or the Fourier basis, based on some pretty elegant, deep math. It's useful any time you want to take a derivative programmatically, such as for doing PDE simulations.

Installation and Usage

The package is a single module containing derivative functions. To install, execute:

python3 -m pip install spectral-derivatives

or from the source code

python3 -m pip install .

You should now be able to

>>> from specderiv import *
>>> import numpy as np
>>>
>>> x_n = np.cos(np.arange(21) * np.pi / 20) # cosine-spaced, includes last point
>>> yx_n = np.sin(x_n) # can be periodic or aperiodic on the domain
>>> dyx_n = cheb_deriv(yx_n, 1)
>>>
>>> th_n = np.arange(20) * 2*np.pi / 20 # equispaced, excludes last point
>>> yth_n = np.sin(th_n) # must be periodic on the domain
>>> dyth_n = fourier_deriv(yth_n, 1)

For further usage examples, see the Jupyter notebooks in the notebooks folder: Chebyshev and Fourier

References

  1. Trefethen, N., 2000, Spectral Methods in Matlab, https://epubs.siam.org/doi/epdf/10.1137/1.9780898719598.ch8
  2. Johnson, S., 2011, Notes on FFT-based differentiation, https://math.mit.edu/~stevenj/fft-deriv.pdf
  3. Kutz, J.N., 2023, Data-Driven Modeling & Scientific Computation, Ch. 11, https://faculty.washington.edu/kutz/kutz_book_v2.pdf

Metadata

Release files for spectral-derivatives 0.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for spectral-derivatives 0.5
File Size Uploaded
spectral_derivatives-0.5.tar.gz 5.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for spectral-derivatives 0.5
File Interpreter ABI Platform
spectral_derivatives-0.5-py3-none-any.whl Python 3 none any Details

Total release size: 11.4 kB

Release files / spectral_derivatives-0.5.tar.gz

Download URL spectral_derivatives-0.5.tar.gz
Size 5.5 kB
Tags Source
SHA-256 checksum
How to use checksums
e18c61e39c3389aa8829ef0582ca441299deaea0751e2ba494b786f0a7fc398a
BLAKE2b-256 checksum
How to use checksums
ae4c0ff5f5f4fdf6218d4fdbc1349ec19fffe4b2dd6b20907421bf5165fc155d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.12.8

Release files / spectral_derivatives-0.5-py3-none-any.whl

Download URL spectral_derivatives-0.5-py3-none-any.whl
Size 5.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
03e10bbdc47c5b6aeabdfe5daab14c3be0d2b458e373eeb50fc2280607d51e99
BLAKE2b-256 checksum
How to use checksums
740243e8455c6dd0e1156b57e136e1260d5d68c17e20f4a8fcae147c4d936af9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.12.8

Release history Release notifications | RSS feed

0.10

2 release files

0.9

2 release files

0.8

2 release files

0.7.4

2 release files

0.7.3

2 release files

0.7.2

2 release files

0.7.1

2 release files

0.7

2 release files

0.6

2 release files

This release

0.5 This release

2 release files

0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page