Skip to content

Commit cb4f81f

Browse files
fix: address PR review comments
Updated module docstring, added validation for non-negative s_value, and replaced arrange with linspace for clarity.
1 parent 4a5c496 commit cb4f81f

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

maths/laplace_transformation.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
"""
2-
This module provides a numerical implementation of the Laplace Transform.
32
4-
https://en.wikipedia.org/wiki/Laplace_transform
3+
Laplace Transform — Numerical Implementation.
4+
5+
Computes the numerical Laplace Transform using the trapezoidal
6+
integration rule. Supports real-valued, non-negative Laplace
7+
parameters only.
8+
9+
Reference: https://en.wikipedia.org/wiki/Laplace_transform
10+
511
612
"""
713

@@ -47,9 +53,11 @@ def laplace_transform(
4753
raise ValueError("delta_t must be a positive value.")
4854
if function_values.size == 0:
4955
raise ValueError("function_values array cannot be empty.")
56+
if s_value < 0:
57+
raise ValueError(f"s_value must be non-negative for this implementation, got{s_value}.")
5058

5159
# Time vector corresponding to the function values
52-
time_vector = np.arange(len(function_values)) * delta_t
60+
time_vector = np.linspace(0, (len(function_values) - 1) * delta_t, len(function_values))
5361

5462
# The integrand: f(t) * e^(-s*t)
5563
integrand = function_values * np.exp(-s_value * time_vector)

0 commit comments

Comments
 (0)