rk4_step {tfNeuralODE} | R Documentation |
Runge Kutta solver for ordinary differential equations
Description
Runge Kutta solver for ordinary differential equations
Usage
rk4_step(func, dt, state)
Arguments
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 |
Value
A list containing a new time and the numerical integration of of the function across the time step to the new time.
Examples
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
[Package tfNeuralODE version 0.1.0 Index]