static double Fe(double e, double r, bool waveFun = false) { double rmin = 1e-3; if (r < rmin) { return(r - r * r); } Func <double, vector, vector> s = delegate(double x, vector y) { return(new vector(y[1], 2 * (-1 / x - e) * y[0])); }; vector ymin = new vector(rmin - rmin * rmin, 1 - 2 * rmin); rk swave = new rk(s, rmin, r, ymin, initStep: 0.001, storeVal: waveFun); //my own 32 stepper if (waveFun) { List <double> rs = rk.ts; List <vector> fs = rk.ys; var data = new StreamWriter("data.txt"); for (int i = 0; i < rs.Count; i++) { data.Write($"{rs[i]} {fs[i][0]} {rs[i]*Exp(-rs[i])}\n"); } data.Close(); } return(swave.yb[0]); }
static void Main() { Func <double, vector, vector> f = delegate(double x, vector y) { return(new vector(y[1], -y[0])); }; rk sincos = new rk(f, 0, 2 * PI, new vector(0, 1), storeVal: true); /* Write($"sin(1) = {sincos.yb[0]}\n"); * Write($"cos(1) = {sincos.yb[1]}\n"); */ List <double> ts = rk.ts; // list to store intermediate t values List <vector> ys = rk.ys; // list to store intermediate f(t) valyes for (int i = 0; i < ts.Count; i++) { Write("{0:f10} {1:f15} {2:f15}\n", ts[i], ys[i][0], ys[i][1]); } }
public Irk Create( ImmutableList <IrkCrossJoinElement> value) { Irk crossJoin = null; try { crossJoin = new rk( value); } catch (Exception exception) { this.Log.Error( exception.Message, exception); } return(crossJoin); }
static void Main() { double N = 550; //population in ten thousands double Tr = 15; //recovery time in days double Tc = 0.01; //time between contacts in days Func <double, vector, vector> f = delegate(double x, vector y) { double n = y[0] + y[1] + y[2]; return(new vector(-y[1] * y[0] / (n * N * Tc), y[1] * y[0] / (n * N * Tc) - y[1] / Tr, y[1] / Tr)); }; rk sir = new rk(f, 0, 150, new vector(550, 1, 0), storeVal: true); /* Write($"sin(1) = {sincos.yb[0]}\n"); * Write($"cos(1) = {sincos.yb[1]}\n"); */ List <double> ts = rk.ts; // list to store intermediate t values List <vector> ys = rk.ys; // list to store intermediate f(t) valyes for (int i = 0; i < ts.Count; i++) { Write("{0:f10} {1:f15} {2:f15} {3:f15}\n", ts[i], ys[i][0], ys[i][1], ys[i][2]); } }