rk4_step | R Documentation |
Runge Kutta solver for ordinary differential equations
rk4_step(func, dt, state)
func |
The function to be numerically integrated. |
dt |
Time step. |
state |
A list describing the state of the function, with the first element being 1, and the second being a tensor that represents state |
A list containing a new time and the numerical integration of of the function across the time step to the new time.
reticulate::py_module_available("tensorflow")
# example code
library(tensorflow)
ode_fun<- function(u){
r = u ^ 3
true_A = rbind(c(-0.1, 2.0), c(-2.0, -0.1))
du <- r %*% (true_A)
return(as.matrix(du))
}
y<- tensorflow::tf$cast(t(as.matrix(c(2, 0))), dtype = tf$float32)
x<- rk4_step(ode_fun, dt = 0.25,
state = list(1.0, y))
x
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.