-
-
Notifications
You must be signed in to change notification settings - Fork 46.7k
Add Fixed Point Iteration and Modified Newton-Raphson Methods #12341
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Click here to look at the relevant links ⬇️
🔗 Relevant Links
Repository:
Python:
Automated review generated by algorithms-keeper. If there's any problem regarding this review, please open an issue about it.
algorithms-keeper
commands and options
algorithms-keeper actions can be triggered by commenting on this PR:
@algorithms-keeper review
to trigger the checks for only added pull request files@algorithms-keeper review-all
to trigger the checks for all the pull request files, including the modified files. As we cannot post review comments on lines not part of the diff, this command will post all the messages in one comment.NOTE: Commands are in beta and so this feature is restricted only to a member or owner of the organization.
""" | ||
|
||
|
||
def fixed_point_iteration(g, x0, tol=1e-7, max_iter=1000): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please provide return type hint for the function: fixed_point_iteration
. If the function does not return a value, please provide the type hint as: def function() -> None:
Please provide type hint for the parameter: g
Please provide descriptive name for the parameter: g
Please provide type hint for the parameter: x0
Please provide type hint for the parameter: tol
Please provide type hint for the parameter: max_iter
|
||
if __name__ == "__main__": | ||
|
||
def g(x): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please provide return type hint for the function: g
. If the function does not return a value, please provide the type hint as: def function() -> None:
Please provide descriptive name for the function: g
Please provide type hint for the parameter: x
Please provide descriptive name for the parameter: x
|
||
|
||
def modified_newton_raphson( | ||
f: Callable[[float], float], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please provide descriptive name for the parameter: f
if __name__ == "__main__": | ||
import math | ||
|
||
def f(x): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please provide return type hint for the function: f
. If the function does not return a value, please provide the type hint as: def function() -> None:
Please provide descriptive name for the function: f
Please provide type hint for the parameter: x
Please provide descriptive name for the parameter: x
def f(x): | ||
return x**3 - 2 * x - 5 | ||
|
||
def f_prime(x): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please provide return type hint for the function: f_prime
. If the function does not return a value, please provide the type hint as: def function() -> None:
Please provide type hint for the parameter: x
Please provide descriptive name for the parameter: x
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
Closing tests_are_failing PRs to prepare for Hacktoberfest |
Describe your change:
This pull request adds two numerical analysis algorithms:
Fixed Point Iteration Method:
An iterative method to find an approximate solution to the equation ( f(x) = 0 ) by rewriting it in the form ( x = g(x) ).
Includes implementation with docstrings, type hints, and doctests.
Modified Newton-Raphson Method:
An iterative method that modifies the standard Newton-Raphson method to improve convergence when the root has multiplicity greater than one.
Includes implementation with docstrings, type hints, and doctests.
Both algorithms are placed in the appropriate directory with filenames in lowercase without spaces or dashes.
Checklist: