adaptive/adaptive.rs
1
2extern crate maths_traits;
3extern crate numerical_integration;
4
5use numerical_integration::*;
6use maths_traits::analysis::metric::InnerProductMetric;
7
8fn main() {
9
10 fn f(_t: f64, y: f64) -> f64 { y }
11
12 let ds = 0.5;
13 // let mut s1 = EULER_HEUN.adaptive_init(0.0, 1.0, ds, &f, InnerProductMetric);
14 // let mut s2 = BOGACKI_SHAMPINE.adaptive_init(0.0, 1.0, ds, &f, InnerProductMetric);
15 // let mut s3 = RK_FELBERG.adaptive_init(0.0, 1.0, ds, &f, InnerProductMetric);
16 let mut s4 = DORMAND_PRINCE.adaptive_init(0.0, 1.0, ds, &f, InnerProductMetric);
17
18 for _ in 0..100 {
19 // let (t, y) = EULER_HEUN.adaptive_step(s1.as_mut(), ds, &f, InnerProductMetric);
20 // let (t, y) = BOGACKI_SHAMPINE.adaptive_step(s3.as_mut(), ds, &f, InnerProductMetric);
21 // let (t, y) = RK_FELBERG.adaptive_step(s3.as_mut(), ds, &f, InnerProductMetric);
22 let (t, y) = DORMAND_PRINCE.adaptive_step(s4.as_mut(), ds, &f, InnerProductMetric);
23 println!("t={} y={} exp(t)={}", t, y, t.exp());
24 // println!("{:?} ", RK_FELBERG.adaptive_step(s2.as_mut(), ds, &f));
25 }
26
27
28}