556 Commits
Author SHA1 Message Date
Christian Clauss 3dae007c74 More ruff rules ANN for type annotations (#15443) 2026-09-26 17:27:43 +02:00
Soham Sharad Patilpre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>Christian Clauss
b3233c9f49 Clarify bitwise operations used in addition without arithmetic (#14059)
* Document addition function using bitwise operations

Added docstring explaining the bitwise addition method.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Refactor addition function documentation and output

Updated docstring to clarify the use of bitwise operations for addition. Modified the output format of the result to include both input values.

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
2026-09-25 07:05:17 +02:00
Seeman Gpre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>Christian Clauss
7a8079f4cd Improve documentation and educational comments in find_max.py (#13017)
* Improve documentation and educational comments in find_max.py

- Added clear explanation of Divide and Conquer approach
- Improved parameter descriptions for better understanding  
- Enhanced comments to explain the algorithm steps
- Better documentation for educational purposes

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
2026-09-25 04:35:51 +02:00
ANDI FAUZAN HEDIANTOROandChristian Clauss b995597167 fix(maths): use specific exception types in collatz_sequence (#14769)
Replace generic Exception with TypeError for non-integer inputs and ValueError for non-positive integers. Split the combined validation check into two separate checks for clearer error reporting. This follows Python best practices for exception handling.

Co-authored-by: Christian Clauss <cclauss@me.com>
2026-09-24 14:20:29 +02:00
ANDI FAUZAN HEDIANTOROandChristian Clauss 026c307820 fix(maths): correct recursive call in sum_of_digits_recursion (#14768)
sum_of_digits_recursion() was calling sum_of_digits() (the iterative version) instead of itself in the recursive case. This meant the function was not actually recursive as its name suggests.

Co-authored-by: Christian Clauss <cclauss@me.com>
2026-09-24 14:10:44 +02:00
c0fd8deab2 Add Jacobsthal numbers to maths/special_numbers (#15409)
Co-authored-by: Rakesh4440 <rakeshvarmaks999@gmail.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
2026-09-23 14:53:42 +02:00
CarlosZamGChristian Clausscclausspre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
836bd712a1 Add algorithm for approximating the nth root with Newton's Method (#11509)
* Add algorithm for approximating the nth root with Newton's Method

* updating DIRECTORY.md

* Fix typos in nth_root.py documentation and code

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: Christian Clauss <cclauss@me.com>
Co-authored-by: cclauss <cclauss@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2026-09-23 07:42:48 +02:00
Arefin_MizanandChristian Clauss 6a2ca6840c Fix binary_exponentiation: integer exponent and floor division, add doctests (#14876)
Co-authored-by: Christian Clauss <cclauss@me.com>
2026-09-22 19:50:18 +02:00
ANDI FAUZAN HEDIANTORO 52b9b913e0 refactor(maths): use direct iteration instead of index-based loops in persistence.py (#14767)
Replace for i in range(len(numbers)) with for number in numbers in both multiplicative_persistence() and additive_persistence(). Direct iteration is more Pythonic and avoids unnecessary index lookups.
2026-09-22 08:34:24 +02:00
francisco a5f5f60cd5 fix typo in binomial_distribution.py output (#14779) 2026-09-22 08:20:57 +02:00
Abhiranjan KumarandChristian Clauss a0b2ef538a Fix incorrect doctest and improve log handling in num_digits functions (#13850)
Co-authored-by: Christian Clauss <cclauss@me.com>
2026-09-22 07:42:30 +02:00
fzeandChristian Clauss 140d410b39 Fix digit count for powers of ten (#14742)
Co-authored-by: Christian Clauss <cclauss@me.com>
2026-09-22 07:19:15 +02:00
CharlesCNortonandChristian Clauss 4aca14b650 Fix ZeroDivisionError on zero operands in least_common_multiple (#14845)
* Fix ZeroDivisionError on zero operands in least_common_multiple

least_common_multiple_slow raised ZeroDivisionError for a zero operand (0 % n in the loop guard), e.g. least_common_multiple_slow(0, 5), and least_common_multiple_fast raised it for (0, 0) via floor-division by gcd(0, 0) == 0. The least common multiple is 0 whenever an operand is 0 (consistent with math.lcm), so both functions return 0 in that case. Adds doctests covering the zero inputs.

* Add zero-operand cases to least_common_multiple unit test

* Apply suggestion from @cclauss

---------

Co-authored-by: Christian Clauss <cclauss@me.com>
2026-09-21 18:28:50 +02:00
SARATHI-78SARATHI-78Christian Clausspre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1c2181944c Add evil_number algorithm in maths/special_numbers (#15388)
* Add evil_number algorithm in maths/special_numbers

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: SARATHI-78 <sundarasarathi78@gmail.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2026-09-21 11:46:50 +02:00
Wu Shuwen 9cf9ad21d2 fix: preserve integer precision in trailing zeroes (#15313) 2026-09-18 02:57:53 +02:00
mohitkumar188 8562a37cf1 Update check_polygon.py (#15320)
Fix polygon side validation and add digon doctest
2026-09-18 02:55:25 +02:00
sayan sompre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>Christian Clausscclauss
def8711701 Add recursive factorial implementation (#14158)
* Add recursive factorial implementation

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* updating DIRECTORY.md

* Fix docstring and update input for factorial functions

Corrected docstring and improved input handling.

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
Co-authored-by: cclauss <cclauss@users.noreply.github.com>
2026-09-17 11:17:58 +02:00
Atharva SJ Pagarandpre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> 688304911c Add alternating harmonic series checker (#14634)
* Add alternating harmonic series checker

* Add reference link for alternating harmonic series

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2026-09-14 07:00:15 +02:00
Chahatpreet Singh e924e42d90 Add first fundamental form calculator to maths (#14554)
This adds a script to calculate the coefficients (e, f, g) of the
first fundamental form for parametric surfaces. This mathematical
framework is a core concept in differential geometry, used to measure
lengths, angles, and areas on a surface.

The implementation uses sympy for symbolic differentiation and
simplification. While standard mathematical notation dictates capital
E, F, and G for these coefficients, they are implemented as lowercase
to strictly adhere to PEP 8 N806 and pass the repository's required
Ruff linter pre-commit hooks.

Reference: https://en.wikipedia.org/wiki/First_fundamental_form

Author: singhc7
2026-09-14 06:58:33 +02:00
BhaktiVagadiaandpre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> 088b4201a1 Alternate harmonic series (#14633)
* add alternate harmonic series

* Add Alternating Harmonic Series

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2026-09-14 06:57:04 +02:00
BhaktiVagadiaandpre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> 9b30c55a12 (Feature)Add a Spy number in Maths->Special Number (#14652)
* enahasment: add spy number in maths-special numbers

* changes in return format

* changes in return format

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2026-09-14 06:55:48 +02:00
Muhammad Zain Ul Abidin ad5ad66713 maths: add autocorrelation function (#14895) 2026-09-14 06:44:26 +02:00
9a51bf91d9 Implementation for Trimorphic Number (#14229)
* Add implementation for Trimorphic Number

An algorithm that checks if a number is trimorphic, which is a number whose cube ends with the same digits as the number itself

* Add doctests for is_trimorphic function

Added doctests for the is_trimorphic function to validate its behavior with various inputs, including edge cases.

* Enhance docstring for is_trimorphic function

Added parameter and return type documentation to is_trimorphic function.

* Rename trimorphic_number.py to maths/special_numbers/trimorphic_number.py

* updating DIRECTORY.md

---------

Co-authored-by: Christian Clauss <cclauss@me.com>
Co-authored-by: cclauss <cclauss@users.noreply.github.com>
2026-09-14 06:41:39 +02:00
prakritim01Prakriti Manharpre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1ac05c75ec Add Padovan Sequence Algorith (#14001)
* Add Padovan Sequence algorithm in maths

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: Prakriti Manhar <prakritim01@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2026-09-14 06:40:45 +02:00
Akhil Devarasetty 167c924ab9 feat: implement shoelace formula for polygon area calculation (#13815)
* feat: implement shoelace formula for polygon area calculation

* feat: add initial bearing calculation function between geographic points
2026-09-14 06:34:36 +02:00
swamini-jadhavandpre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> 01963e0ce5 Next Prime Number (#13631)
* Add Next_Prime_Number with prime checking logic

Implement function to find the next prime number.

* Rename Next_Prime_Number.py to next_prime_number.py

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Refactor prime number functions and add type hints

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2026-09-14 06:27:39 +02:00
Varun Arorapre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>Christian Clausscclauss
6c402a3e18 Add Python function to check Disarium numbers (#13603)
* Add Python function to check Disarium numbers

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* updating DIRECTORY.md

* Add documentation link for Disarium number check

Added a link to Rosetta Code for Disarium numbers.

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
Co-authored-by: cclauss <cclauss@users.noreply.github.com>
2026-09-14 06:27:14 +02:00
Raman Vasikarlarvasikarlapre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>Christian Clausscclauss
ccc4b19ea4 Add comprehensive test coverage for maths.abs module (#13588)
* Add comprehensive test coverage for maths.abs module
- Added test_abs.py with pytest-compatible tests- Tests cover abs_val, abs_min, abs_max, and abs_max_sort functions- Includes edge cases, error conditions, and consistency checks
- Follows existing test patterns in the repository- Improves test coverage for issue #9943

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Fix import formatting for ruff linter compliance

* updating DIRECTORY.md

---------

Co-authored-by: rvasikarla <rvasikarla@splunk.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
Co-authored-by: cclauss <cclauss@users.noreply.github.com>
2026-09-14 06:26:37 +02:00
Raj Srivastavapre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>Christian Clausscclauss
dca13f6ff9 Implement Gauss-Seidel method for solving linear systems. (#13535)
* Add Gauss-Seidel method implementation

Implement Gauss-Seidel method for solving linear systems.

* Update gauss-seidel-method.py

* Rename gauss-seidel-method.py to gauss_seidel_method.py

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Rename parameters in Gauss-Seidel method

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Enhance gauss_seidel function documentation and code style

Refactor gauss_seidel method for improved readability and clarity.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Enhance Gauss-Seidel method with result rounding

Added rounding to results for stable test comparison.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Clean up comments in Gauss-Seidel method

Removed comments related to convergence check and result rounding.

* updating DIRECTORY.md

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
Co-authored-by: cclauss <cclauss@users.noreply.github.com>
2026-09-14 06:25:41 +02:00
9523b684cc Add generalized nCr (combinations) calculator for real n and integer r (#13623)
* Create ncr_combinations.py

* Update ncr_combinations.py

* Update ncr_combinations.py

* Update ncr_combinations.py

* Update ncr_combinations.py

* updating DIRECTORY.md

---------

Co-authored-by: Christian Clauss <cclauss@me.com>
Co-authored-by: cclauss <cclauss@users.noreply.github.com>
2026-09-14 06:24:09 +02:00
Parth Mittalpre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>Christian Clausscclauss
2d75c9c783 Create reverse_factorial_recursive.py (#13426)
* Create reverse_factorial_recursive.py

Added reverse factorial recursive algorithm with doctests

* Update reverse_factorial_recursive.py

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update reverse_factorial_recursive.py

* updating DIRECTORY.md

* Refactor docstring and include doctest

Updated docstring formatting and added doctest.

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
Co-authored-by: cclauss <cclauss@users.noreply.github.com>
2026-09-14 06:20:41 +02:00
Arun Kishore VoletiArunKishoreVoletipre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>Christian Clausscclauss
2922216901 Add function to check abundant numbers (#13527)
* Add function to check abundant numbers

Introduces is_abundant_number to determine if a number is abundant by checking if the sum of its proper divisors exceeds the number itself. Includes doctests and input validation.

* updating DIRECTORY.md

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* updating DIRECTORY.md

* Clarify return value in is_abundant_number function

Updated docstring to clarify the function's return value.

---------

Co-authored-by: ArunKishoreVoleti <ArunKishoreVoleti@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
Co-authored-by: cclauss <cclauss@users.noreply.github.com>
2026-09-14 06:17:32 +02:00
Arun Kishore VoletiArunKishoreVoletipre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>Christian Clausscclauss
d49e82b3e9 Add function to check deficient numbers (#13528)
* Add function to check deficient numbers

Introduces is_deficient_number to determine if a number is deficient by comparing the sum of its proper divisors to the number itself. Includes input validation and doctests for correctness.

* updating DIRECTORY.md

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update deficient_numbers.py

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update deficient_numbers.py

Fixed code issue

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* updating DIRECTORY.md

* Add docstring for deficient number explanation

Added a docstring explaining deficient numbers and provided examples.

---------

Co-authored-by: ArunKishoreVoleti <ArunKishoreVoleti@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
Co-authored-by: cclauss <cclauss@users.noreply.github.com>
2026-09-14 06:15:10 +02:00
Arun Kishore VoletiArunKishoreVoletipre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>Christian Clausscclauss
378f30c03a Add Disarium number checker implementation (#13529)
* Add Disarium number checker implementation

Introduces is_disarium_number function to check if a number is a Disarium number, including input validation and doctests for various cases.

* updating DIRECTORY.md

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* updating DIRECTORY.md

* Clarify Disarium number definition in comments

Updated the definition of a Disarium number for clarity.

---------

Co-authored-by: ArunKishoreVoleti <ArunKishoreVoleti@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
Co-authored-by: cclauss <cclauss@users.noreply.github.com>
2026-09-14 06:14:27 +02:00
Valentin KlingerChristian Clausscclausspre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>pre-commit-ci[bot] <pre-commit-ci[bot]@users.noreply.github.com>
b472cbcb9b Added a polygon triangulation algorithm with the ear clipping method. (#10466)
* Added a polygon triangulation algorithm with the ear clipping method. (ear_clipping_polygon_triangulation.py)

* Clarification of parameter names and provide type hint for a parameter in maths/ear_clipping_polygon_triangulation.py. (Action requested by algorithms-keeper bot).

* updating DIRECTORY.md

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* updating DIRECTORY.md

---------

Co-authored-by: Christian Clauss <cclauss@me.com>
Co-authored-by: cclauss <cclauss@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <pre-commit-ci[bot]@users.noreply.github.com>
2026-09-14 06:09:21 +02:00
Aditya Balotra df4a6528c5 Binomial Expansion (#12875)
* Add binomial_expansion function building on binomial_coefficient

- Computes (a + b)^n for both positive and negative integer exponents
- Uses existing binomial_coefficient function for term computation
- Raises ZeroDivisionError when base is 0 and exponent is negative
- Includes doctests and example cases

* add URL
2026-09-14 06:02:20 +02:00
ea50993310 Implement IPv6 address validation algorithm (#13055)
* add IPv6 address validator with doctests

* update documentation to include the references

* Enhance _is_valid_group with detailed docstring

Added docstring to _is_valid_group function with examples.

---------

Co-authored-by: Jishnu-Pramod <Jishnu.Pramod@ibm.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
2026-09-14 06:01:39 +02:00
Nefelibata be65e47b54 Add Digital Root algorithm to maths (#14988)
* Add digital root algorithm

* refactor: use descriptive parameter name `number` instead of `n` (algorithms-keeper)

Also see: project_euler/problem_092/sol1.py
2026-09-13 13:38:39 +02:00
78255cb1c7 Update pi monte carlo script to run tests with fixed seed. (#12757)
* Update pi monte carlo script to run tests with fixed seed.

* updating DIRECTORY.md

* Update pi_monte_carlo_estimation.py

* Import pi from math module

---------

Co-authored-by: Christian Clauss <cclauss@me.com>
Co-authored-by: cclauss <cclauss@users.noreply.github.com>
2026-09-13 10:22:38 +02:00
priya-sundaram-dev 9cd7ee0c59 maths/softmax: clear errors for non-numeric input, axis=None, edge-case doctests (#15312)
Closes the remaining items in #13171: friendly ValueError for non-numeric
inputs (str/dict) instead of raw numpy messages, optional axis=None for a
whole-array distribution, documented NaN/inf behavior, and doctests covering
identical logits, large (overflow-prone) logits, 2-D axis selection, empty
input, non-numeric input, and out-of-bounds axis.
2026-09-13 10:00:19 +02:00
Christian Clauss 0525ef5da8 ruff rule ANN202 missing-return-type-private-function (#15298)
* ruff rule ANN202 missing-return-type-private-function

* ruff rule ANN202 missing-return-type-private-function
2026-09-12 21:47:08 +02:00
Christian Clauss 0da45b148a ruff rule ANN204 missing-return-type-special-method (#15300) 2026-09-12 21:35:04 +02:00
Christian Claussandcclauss 7bd1e983c3 ruff rules RET for return statements (#15301)
* updating DIRECTORY.md

* ruff rules RET for return statements

---------

Co-authored-by: cclauss <cclauss@users.noreply.github.com>
2026-09-12 21:33:52 +02:00
SYED ANNAS JAWED b7f4f02ee6 fix: use averaged ranks for ties in Spearman, guard n<2 (#14889) 2026-09-10 12:22:25 +02:00
SudoShellzandsudo-ai-git df92771a19 fix(maths): defer Matrix type annotations so import does not NameError (#15265)
Importing maths.matrix_exponentiation raised 'NameError: name Matrix is
not defined' because __mul__ and modular_exponentiation annotate with
Matrix before the class name is bound (annotations evaluate eagerly at
class-body execution time).

Add 'from __future__ import annotations' to defer annotation evaluation,
matching the pattern used elsewhere in the repo.

Verified on current master: import succeeds (NameError gone) and all 10
doctests pass.

Signed-off-by: sudo-ai-git <sudo-ai-git@users.noreply.github.com>
Co-authored-by: sudo-ai-git <sudo-ai-git@users.noreply.github.com>
2026-09-10 07:42:13 +02:00
Tushar TyagiCopilotpre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
62d049a60f feat: add numerical laplace transform (#14602)
* feat: add numerical laplace transform

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update maths/laplace_transformation.py

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* refactor: add input validation and fix doctest precision

* fix: address PR review comments

Updated module docstring, added validation for non-negative s_value, and replaced arrange with linspace for clarity.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Refactor docstring and remove unnecessary blank lines

Removed extra blank lines and cleaned up docstring.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Refactor error handling for s_value check

* Fix indentation for s_value validation

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-09-08 17:54:08 +02:00
iQuantumpre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>Christian Clauss
3374edec1c Add Sieve of Atkin algorithm for efficient prime generation (#12974)
* Add Sieve of Atkin algorithm for efficient prime generation

Implement the Sieve of Atkin algorithm as an alternative to the existing
Sieve of Eratosthenes. This modern algorithm offers better theoretical
complexity O(n / log log n) and uses quadratic forms for prime detection.

Features:
- Comprehensive docstring with algorithm explanation
- Type hints and input validation
- Extensive doctests covering edge cases
- Follows repository coding conventions

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Fix: add missing newline at end of file

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Delete pr_description.txt

* Enhance documentation for Sieve of Atkin

Added additional explanation about the Sieve of Atkin algorithm.

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
2026-09-08 17:51:29 +02:00
debesh00800debeshpre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>Christian Clauss
16e3b40408 Add Brent's Method for root finding (numerical analysis) (#13063)
* Add Brent's Method for root finding (numerical analysis)

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Fix parameter names and lint issues in Brent's Method

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Fix import name

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Rename maths/brent_method.py to maths/numerical_analysis/brent_method.py

---------

Co-authored-by: debesh <debeshmaheshwari008@gmail.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
2026-09-08 17:43:43 +02:00
Felipe Fernandes — Systems & AI Engineerandpre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> 657c967afb Add Tonelli-Shanks algorithm for modular square roots (#14995)
* Add Tonelli-Shanks modular square root algorithm.

Implements Legendre symbol checks and both the p≡3 (mod 4) fast path and
the full Tonelli-Shanks procedure, with doctests for success and error cases.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Fix ruff EM102 by assigning exception messages before raise.

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2026-09-08 15:50:20 +02:00
NostraWhopre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>Christian Clauss
beca49787a Add improved doctrings and doctests for math/perfect_number.py (#12830)
* Add improved doctrings and doctests for math/perfect_number.py

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
2026-09-08 15:28:10 +02:00