- #1
Cincinnatus
- 389
- 0
I'm trying to write a program in python to solve a system of differential equations using the 4th order Runga-Kutta method.
I would ideally like the program to be able to solve systems of arbitrary size. To do this, I believe I will need to write a function (rk4) that would take as argument another function (the derivs function).
I've never written anything like that before though, I'm not exactly sure how to go about it...
Could I write something like:
def rk4 (derivs,whatever else) :
.
.
.
whatever=derivs(arguments)
.
.
.
return array of solutions
Is there any special syntax involved in having one function take another as an argument like this?
Is there anything else I should know before I try writing this?
I would ideally like the program to be able to solve systems of arbitrary size. To do this, I believe I will need to write a function (rk4) that would take as argument another function (the derivs function).
I've never written anything like that before though, I'm not exactly sure how to go about it...
Could I write something like:
def rk4 (derivs,whatever else) :
.
.
.
whatever=derivs(arguments)
.
.
.
return array of solutions
Is there any special syntax involved in having one function take another as an argument like this?
Is there anything else I should know before I try writing this?