I would prefer to implement the function as a generator, which would allow you to avoid storing all y values in memory and reduce memory consumption when working with large ranges.
The RK4 function does not exit, but saves its state, allowing you to continue obtaining y values in the loop.
Might it be neater if, instead of returning a list of y values, you had to return a function? The function could then be called at a specific x and could return the correct value if x was a mulitple of h. It could then use linear interpolation for the bits inbetween and raise an error if x is not in the domain.
Just a suggestion...
Python fork that fixes that issue, please review.
I would prefer to implement the function as a generator, which would allow you to avoid storing all y values in memory and reduce memory consumption when working with large ranges.
The RK4 function does not exit, but saves its state, allowing you to continue obtaining y values in the loop.
Might it be neater if, instead of returning a list of y values, you had to return a function? The function could then be called at a specific x and could return the correct value if x was a mulitple of h. It could then use linear interpolation for the bits inbetween and raise an error if x is not in the domain.
Just a suggestion...