Runge-Kutta method: Difference between revisions
Content deleted Content added
Minor formatting changes. Using "strformat". Updated output. |
|||
Line 3,037: | Line 3,037: | ||
=={{header|Rust}}== |
=={{header|Rust}}== |
||
This is a translation of the javascript solution with some minor differences. |
This is a translation of the javascript solution with some minor differences. |
||
<lang rust>fn runge_kutta4(fx: &Fn(f64, f64) -> f64, x: f64, y: f64, dx: f64) -> f64 { |
<lang rust>fn runge_kutta4(fx: &dyn Fn(f64, f64) -> f64, x: f64, y: f64, dx: f64) -> f64 { |
||
let k1 = dx * fx(x, y); |
let k1 = dx * fx(x, y); |
||
let k2 = dx * fx(x + dx / 2.0, y + k1 / 2.0); |
let k2 = dx * fx(x + dx / 2.0, y + k1 / 2.0); |