Skip to content

added rkf45 method #10438

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

Merged
merged 19 commits into from
Oct 15, 2023
Merged

added rkf45 method #10438

merged 19 commits into from
Oct 15, 2023

Conversation

ravi-ivar-7
Copy link
Contributor

Add an algorithm (rkf45) to TheAlgorithms / Python/maths

@algorithms-keeper algorithms-keeper bot added the tests are failing Do not merge until tests pass label Oct 14, 2023
@algorithms-keeper algorithms-keeper bot added the awaiting reviews This PR is ready to be reviewed label Oct 14, 2023
Copy link
Contributor Author

@ravi-ivar-7 ravi-ivar-7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed whitespace

@ravi-ivar-7
Copy link
Contributor Author

removed some whitespace

Copy link
Contributor Author

@ravi-ivar-7 ravi-ivar-7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated rkf45.py as per suggestions

@ravi-ivar-7
Copy link
Contributor Author

updated rkf45.py as per suggestions

maths/rkf45.py Outdated
#excact value of y[1] is tan(0.2) = 0.2027100355086
>>> def f(x,y):
... return 1+y**2
>>> y=rkf45(f,0,0,0.2,1)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
>>> y=rkf45(f,0,0,0.2,1)
>>> y=rkf45(f, 0, 0, 0.2, 1)

@algorithms-keeper algorithms-keeper bot added awaiting changes A maintainer has requested changes to this PR and removed awaiting reviews This PR is ready to be reviewed labels Oct 14, 2023
@algorithms-keeper algorithms-keeper bot added awaiting reviews This PR is ready to be reviewed and removed awaiting changes A maintainer has requested changes to this PR labels Oct 15, 2023
Copy link
Contributor Author

@ravi-ivar-7 ravi-ivar-7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Improved Code Quality

@algorithms-keeper algorithms-keeper bot removed the tests are failing Do not merge until tests pass label Oct 15, 2023
maths/rkf45.py Outdated
Comment on lines 35 to 37
>>> y=runge_futta_fehlberg_45(f, 0, 0, 0.2, 1)
>>> y[1]
0.2027100937470787
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We will need more than one test. What happens if x_initial is set to 5, -5, 5.5?

What happens if step_size is zero or negative?

What happens if x_final is zero or negative?

What happens if ode is 5 instead of being a function?

Let's have a test that raises a RangeError.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Condition on x_initial and x_final is that x_final should be greater than x_initial. They can be zero , negative or positive.
  2. Added exception for step_size as it should be positive.
  3. ode can be a constant function or a function of x and/or y.

@algorithms-keeper algorithms-keeper bot added the tests are failing Do not merge until tests pass label Oct 15, 2023
Copy link
Contributor Author

@ravi-ivar-7 ravi-ivar-7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added more test cases and exception.

maths/rkf45.py Outdated
Comment on lines 35 to 37
>>> y=runge_futta_fehlberg_45(f, 0, 0, 0.2, 1)
>>> y[1]
0.2027100937470787
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Condition on x_initial and x_final is that x_final should be greater than x_initial. They can be zero , negative or positive.
  2. Added exception for step_size as it should be positive.
  3. ode can be a constant function or a function of x and/or y.

@ravi-ivar-7
Copy link
Contributor Author

Added more test cases and exception.

@algorithms-keeper algorithms-keeper bot removed the tests are failing Do not merge until tests pass label Oct 15, 2023
@cclauss cclauss enabled auto-merge (squash) October 15, 2023 09:06
@cclauss cclauss merged commit 7dbc301 into TheAlgorithms:master Oct 15, 2023
@algorithms-keeper algorithms-keeper bot removed the awaiting reviews This PR is ready to be reviewed label Oct 15, 2023
@cclauss
Copy link
Member

cclauss commented Oct 15, 2023

Nice one! It is great that you deal with invalid input.

@ravi-ivar-7
Copy link
Contributor Author

@cclauss : Please add hacktoberfest-accepted label so that it can be accepted in hacktoberfest.

@cclauss cclauss added the hacktoberfest-accepted Accepted to be counted towards Hacktoberfest label Oct 15, 2023
@ravi-ivar-7 ravi-ivar-7 deleted the algo_maths branch October 15, 2023 11:20
sedatguzelsemme pushed a commit to sedatguzelsemme/Python that referenced this pull request Sep 15, 2024
* added rkf45 method

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

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

* Updated rkf45.py

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

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

* Updated rkf45.py

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

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

* Update rkf45.py

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

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

* Update rkf45.py with suggestions

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

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

* Improved Code Quality rkf45.py

* Added more test cases and exception rkf45.py

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

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

* Update rkf45.py

* corrected some spellings. rkf45.py

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

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

* Update rkf45.py

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

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

* Update rkf45.py

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Christian Clauss <[email protected]>
@isidroas isidroas mentioned this pull request Jan 25, 2025
14 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hacktoberfest-accepted Accepted to be counted towards Hacktoberfest
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants