Uh oh!
There was an error while loading. Please reload this page.
added rkf45 method - #10438
Conversation
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
iamrknain
left a comment
There was a problem hiding this comment.
Removed whitespace
iamrknain
commented
Oct 14, 2023
removed some whitespace |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
iamrknain
left a comment
There was a problem hiding this comment.
updated rkf45.py as per suggestions
iamrknain
commented
Oct 14, 2023
updated rkf45.py as per suggestions |
Uh oh!
There was an error while loading. Please reload this page.
| #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) |
There was a problem hiding this comment.
| >>>y=rkf45(f,0,0,0.2,1) | |
| >>>y=rkf45(f,0, 0, 0.2,1) |
Uh oh!
There was an error while loading. Please reload this page.
iamrknain
left a comment
There was a problem hiding this comment.
Improved Code Quality
Uh oh!
There was an error while loading. Please reload this page.
| >>> y=runge_futta_fehlberg_45(f, 0, 0, 0.2, 1) | ||
| >>> y[1] | ||
| 0.2027100937470787 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
- Condition on x_initial and x_final is that x_final should be greater than x_initial. They can be zero , negative or positive.
- Added exception for step_size as it should be positive.
- ode can be a constant function or a function of x and/or y.
iamrknain
left a comment
There was a problem hiding this comment.
Added more test cases and exception.
Uh oh!
There was an error while loading. Please reload this page.
| >>> y=runge_futta_fehlberg_45(f, 0, 0, 0.2, 1) | ||
| >>> y[1] | ||
| 0.2027100937470787 |
There was a problem hiding this comment.
- Condition on x_initial and x_final is that x_final should be greater than x_initial. They can be zero , negative or positive.
- Added exception for step_size as it should be positive.
- ode can be a constant function or a function of x and/or y.
iamrknain
commented
Oct 15, 2023
Added more test cases and exception. |
for more information, see https://pre-commit.ci
cclauss
commented
Oct 15, 2023
Nice one! It is great that you deal with invalid input. |
iamrknain
commented
Oct 15, 2023
@cclauss : Please add hacktoberfest-accepted label so that it can be accepted in hacktoberfest. |
Add an algorithm (rkf45) to TheAlgorithms / Python/maths