Repository navigation
Description
Student: Pruthviraj Gojare
Task: R23-T047 · 7 of 10
Repository: https://github.com/S-AI-Projects/TheAlgorithms-Python
Assigned working branch: student/e26b07f0834
Goal
Explore the repository for related implementations and compare their interfaces, results and speed. Compare with maths/euler_modified.py and maths/runge_kutta.py on dy/dx = y, y(0)=1 over [0,1]: error vs step size.
Steps
- Locate the related files named in the goal (use
grep -rl/ DIRECTORY.md) and read them. - Write work/R23-T047/compare_test.py checking that the implementations agree on at least 10 shared inputs (or explaining why they cannot).
- Benchmark them on the same inputs.
- Write COMPARE.md: API differences, results, speed, and which you would recommend to a beginner.
- Make the code change in the repository: maths/euler_method.py: docstring comparing its error with euler_modified.py and runge_kutta.py on dy/dx = y, with a doctest. Re-run the automated check and the repo's own tests afterwards.
- Prepare the PR: on branch R23-T047, commit the code change plus your work/R23-T047/ evidence, put your findings in the PR description and open the PR against the org fork. For a later upstream PR, create a second branch containing only the code change (no work/ folder).
Done when
☐ compare_test.py solves dy/dx = y, y(0) = 1 on [0, 1] with explicit_euler, euler_modified and runge_kutta for step sizes 0.1, 0.05 and 0.025.
☐ COMPARE.md error table vs e shows the expected orders (Euler ~O(h), modified ~O(h²), RK4 ~O(h⁴)).
☐ maths/euler_method.py docstring gains the comparison and a doctest; existing 5 doctests pass.
Additional task guidance
Additional curated task guidance
Item:
maths/euler_method.py (47 lines; 5 doctests)
Task type:
Compare implementations
Code change (goes into the PR):
maths/euler_method.py: docstring comparing its error with euler_modified.py and runge_kutta.py on dy/dx = y, with a doctest.
Automated check:
uv run pytest work/R23-T047/compare_test.py
Prerequisites:
Linux/WSL2/Codespaces with uv (https://docs.astral.sh/uv/getting-started/installation/); run uv sync --group=test once – it installs the Python version CI uses (.python-version = 3.15t) and the test dependencies, about 1–2 GB
Upstream PR rules:
Follow CONTRIBUTING.md: type hints on every parameter/return, doctests for valid and erroneous input, snake_case file names, no duplicate of an existing implementation, no hand edits to DIRECTORY.md. CI (pytest with doctests, ruff) must pass – bots close PRs without tests or type hints. Keep work/ (benchmarks, notes, property tests) out of the upstream branch; put results in the PR description.
Source (pinned):
https://github.com/TheAlgorithms/Python/blob/574d100b7181956e9c8384552fd078165e4cc326/maths/euler_method.py
Change:
No change recorded
PR destination:
Preserved pilot guidance
Submission checklist
- Complete this task and its checks.
- Add the required evidence and link your pull request here.
- Select this S-AI-Projects fork as the PR base repository.
- Request instructor review.
Keep this PR focused on this task. Do not submit assignment PRs to the upstream repository.
Activity