Skip to main content

timevar-poly: A lightweight engine for time-variant polynomials.

Project description

📈 timevar-poly

timevar-poly is a lightweight Python engine designed to manipulate polynomials whose coefficients vary over time. It bridges the gap between symbolic structure and numerical evaluation, allowing for complex algebraic operations and derivatives.

✨ Key Features

  • Dynamic Coefficients: Use any Python function (sin, cos, exp, etc.) or constants as polynomial coefficients.
  • Hybrid Computation: Combines the structural benefits of polynomials with the flexibility of time-dependent functions.
  • Partial Evaluation (Currying): Intelligently "freeze" either the spatial variable ($x$) or the temporal variable ($t$) to obtain specialized objects.
  • Advanced Derivatives: Full support for spatial derivatives ($\frac{\partial F}{\partial x}$), temporal derivatives ($\frac{\partial F}{\partial t}$), and mixed partial derivatives.

🚀 Installation

pip install timevar-poly

🛠 Quick Start

1. Define a Polynomial

Let's define $F(x, t) = \cos(t)x + \sin(t)$:

import math
from timevar_poly import TimeFunction, TimeVariantPolynomial

F = TimeVariantPolynomial({
    1: TimeFunction(math.cos),
    0: TimeFunction(math.sin)
}, label="F")

print(F) # Output: (cos(t))x + (sin(t))

2. The Power of Currying

You can evaluate one dimension while keeping the other as a variable:

# Fix time: Returns a standard Polynomial in x
P_at_t1 = F(t=1)
print(P_at_t1) # Outputs numerical coefficients evaluated at t=1

# Fix space: Returns a pure TimeFunction of t
f_at_x2 = F(x=2)
print(f_at_x2) # Output: F(2, t)
print(f_at_x2(0)) # Calculates the value at t=0

3. Calculus

# Derivative with respect to x
df_dx = F.diff_x()

# Derivative with respect to time (t)
df_dt = F.diff_t()

# Mixed second-order derivative (Schwarz's Theorem)
d2f_dtdx = F.diff_x().diff_t()
d2f_dxdt = F.diff_t().diff_x()

assert math.isclose(d2f_dtdx(2, 1), d2f_dxdt(2, 1), rel_tol=1e-9) # Should be True

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

👤 Author

Ifèdé Assogba - Creator of the timevar-poly engine

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

timevar_poly-0.2.0.tar.gz (4.9 kB view details)

Uploaded Source

Built Distribution

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

timevar_poly-0.2.0-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

Details for the file timevar_poly-0.2.0.tar.gz.

File metadata

  • Download URL: timevar_poly-0.2.0.tar.gz
  • Upload date:
  • Size: 4.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.32.5

File hashes

Hashes for timevar_poly-0.2.0.tar.gz
Algorithm Hash digest
SHA256 77e07f46a91022fb8ff302c8aae38be77b3c9ca4857bece4aadd5891bcd29e53
MD5 8ffef976d7dd558b5ae7902a0e2771c4
BLAKE2b-256 f58fa6796259f2f368c817f045a6eb2ebc99799fe7be5abb0190b626e292354e

See more details on using hashes here.

File details

Details for the file timevar_poly-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: timevar_poly-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 5.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.32.5

File hashes

Hashes for timevar_poly-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9d8d4ad8a7463c7400ddb5fbf5375e591dc3c1f97491aef5d045541c01c015a2
MD5 ea0ce6c5c0302d84ec4fb9aca38eb1dd
BLAKE2b-256 e59c0467e9bfa1fce24badcab7cd4a868e2aa1e56852ed3c0a4f47e4b435a127

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