Skip to content

feat: add numerical laplace transform#14602

Open
Tushar-R-Tyagi wants to merge 5 commits intoTheAlgorithms:masterfrom
Tushar-R-Tyagi:master
Open

feat: add numerical laplace transform#14602
Tushar-R-Tyagi wants to merge 5 commits intoTheAlgorithms:masterfrom
Tushar-R-Tyagi:master

Conversation

@Tushar-R-Tyagi
Copy link
Copy Markdown

Describe your change:

I have added a numerical implementation of the Laplace transform in the maths/ directory.

  • Add an algorithm?
  • Fix a bug or typo in an existing algorithm?
  • Add or change doctests? -- Note: Please avoid changing both code and tests in a single pull request.
  • Documentation change?

Checklist:

  • I have read CONTRIBUTING.md.
  • This pull request is all my own work -- I have not plagiarized.
  • I know that pull requests will not be merged if they fail the automated tests.
  • This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms.
  • All new Python files are placed inside an existing directory.
  • All filenames are in all lowercase characters with no spaces or dashes.
  • All functions and variable names follow Python naming conventions.
  • All function parameters and return values are annotated with Python type hints.
  • All functions have doctests that pass the automated testing.
  • All new algorithms include at least one URL that points to Wikipedia or another similar explanation.
  • If this pull request resolves one or more open issues then the description above includes the issue number(s) with a closing keyword: "Fixes #ISSUE-NUMBER".

Copilot AI review requested due to automatic review settings April 28, 2026 18:34
@algorithms-keeper algorithms-keeper Bot added the awaiting reviews This PR is ready to be reviewed label Apr 28, 2026
@Tushar-R-Tyagi
Copy link
Copy Markdown
Author

pre-commit.ci autofix

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a numerical (sampled-data) Laplace transform implementation to the maths/ algorithms collection.

Changes:

  • Introduces laplace_transform() that applies an exponential kernel and integrates via the trapezoidal rule.
  • Adds doctest examples for two basic reference functions.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread maths/laplace_transformation.py Outdated
Comment thread maths/laplace_transformation.py
Comment thread maths/laplace_transformation.py
Comment thread maths/laplace_transformation.py Outdated
Comment on lines +43 to +44
if s_value < 0:
raise ValueError("s_value must be non-negative for convergence.")
Copy link

Copilot AI Apr 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The convergence check if s_value < 0: raise ... is not generally correct for the Laplace transform (e.g., for f(t)=e^{-t}, the transform converges for Re(s) > -1). Also, since this implementation integrates over a finite sampled window, negative s_value won't inherently diverge. Consider removing this restriction, or (if you keep it) documenting it as a deliberate limitation rather than a convergence requirement.

Copilot uses AI. Check for mistakes.
Comment thread maths/laplace_transformation.py
@algorithms-keeper algorithms-keeper Bot added the tests are failing Do not merge until tests pass label Apr 28, 2026
@algorithms-keeper algorithms-keeper Bot removed the tests are failing Do not merge until tests pass label Apr 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting reviews This PR is ready to be reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants