added rkf45 method#10438
added rkf45 method#10438cclauss merged 19 commits intoTheAlgorithms:masterfrom ravi-ivar-7:algo_maths
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
for more information, see https://pre-commit.ci
ravi-ivar-7
left a comment
There was a problem hiding this comment.
Removed whitespace
|
removed some whitespace |
for more information, see https://pre-commit.ci
ravi-ivar-7
left a comment
There was a problem hiding this comment.
updated rkf45.py as per suggestions
|
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) |
There was a problem hiding this comment.
| >>> y=rkf45(f,0,0,0.2,1) | |
| >>> y=rkf45(f, 0, 0, 0.2, 1) |
ravi-ivar-7
left a comment
There was a problem hiding this comment.
Improved Code Quality
maths/rkf45.py
Outdated
| >>> 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.
ravi-ivar-7
left a comment
There was a problem hiding this comment.
Added more test cases and exception.
maths/rkf45.py
Outdated
| >>> 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.
|
Added more test cases and exception. |
for more information, see https://pre-commit.ci
|
Nice one! It is great that you deal with invalid input. |
|
@cclauss : Please add hacktoberfest-accepted label so that it can be accepted in hacktoberfest. |
Add an algorithm (rkf45) to TheAlgorithms / Python/maths