Skip to content

test(math): add Liouville function complexity analysis (R50-T039) - #77

Open
nishadaniket174 wants to merge 1 commit into
S-AI-Projects:masterfrom
nishadaniket174:student/e26b07f0789/R50-T039
Open

nishadaniket174 wants to merge 1 commit into
S-AI-Projects:masterfrom
nishadaniket174:student/e26b07f0789/R50-T039

Conversation

@nishadaniket174

@nishadaniket174 nishadaniket174 commented Nov 16, 2026 •

Copy link
Copy Markdown

Summary

This PR adds complexity analysis, empirical performance measurements, and regression tests for liouvilleFunction in Maths/LiouvilleFunction.js.

The implementation calculates the Liouville function λ(n) based on the total number of prime factors, counted with multiplicity. This contribution documents its complexity and verifies correctness across different input sizes.

Changes Made

  • Improved the function's JSDoc with:
    • Input and return-value descriptions.
    • Theoretical worst-case time complexity: O(√n).
    • Theoretical best-case time complexity: O(log n).
    • Auxiliary space complexity: O(log n).
    • Empirical scaling observations.
  • Expanded Maths/test/LiouvilleFunction.test.js with explicit fixtures:
    • Smallest valid input: 1 → 1.
    • Ordinary input: 12 → -1.
    • Large composite input: 1,000,000 → 1.
    • Large prime input: 999,983 → -1.
  • Added checks for repeatability, input purity, and consistent results across interleaved calls.
  • Added source-line precondition references and independently calculated expected values.
  • Added work/R50-T039/experiment.js for deterministic complexity and scaling measurements using fixed-seed inputs, five repetitions per size, and median/range reporting.
  • Added work/R50-T039/check.py to automate focused tests, the complexity experiment, deliberate mutation verification, and the full repository test suite.

Testing and Verification

The following checks passed:

  • Focused tests: npx vitest run Maths/test/LiouvilleFunction.test.js (106 tests passed).
  • Complexity experiment: node work/R50-T039/experiment.js completed successfully.
  • Deliberate mutation check: confirmed that deliberately inverting the parity condition causes the tests to fail.
  • Full repository test suite: npm test (347 test files passed, 12,027 tests passed).
  • Code style: npm run check-style passed.

Run the complete task-specific verification using:

python3 work/R50-T039/check.py

Related Issue

Closes #39

Task: R50-T039
Target file: Maths/LiouvilleFunction.js
Function: liouvilleFunction

All task-specific evidence and benchmark results are maintained under work/R50-T039/.

@nishadaniket174
nishadaniket174 force-pushed the student/e26b07f0789/R50-T039 branch from 94946f9 to afe9ed8 Compare November 21, 2026 14:33
@nishadaniket174 nishadaniket174 changed the title Student/e26b07f0789/r50 t039 test(math): add Liouville function complexity analysis (R50-T039) Nov 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ANIKET KUMAR NISHAD — R50-T039: Measure the work done by liouvilleFunction (LiouvilleFunction.js) [Maths/LiouvilleFunction.js]

1 participant