TFinal = 30;
TFinal = 30;
Subscript[a, 11] = 0.9;
Subscript[a, 12] = 0.0005;
Subscript[a, 13] = 0.055;
Subscript[a, 21] = 1.7000;
Subscript[a, 22] = 0.075;
Fehlbergamat = {{1/4}, {3/32, 9/32}, {1932/2197, -7200/2197,
7296/2197}, {439/216, -8, 3680/513, -845/4104}, {-8/27,
2, -3544/2565, 1859/4104, -11/40}};
Fehlbergbvec = {25/216, 0, 1408/2565, 2197/4104, -1/5, 0};
Fehlbergcvec = {1/4, 3/8, 12/13, 1, 1/2};
Fehlbergevec = {-1/360, 0, 128/4275, 2197/75240, -1/50, -2/55};
FehlbergCoefficients[4, p_] :=
N[{Fehlbergamat, Fehlbergbvec, Fehlbergcvec, Fehlbergevec}, p];
Fehlberg45 = {"ExplicitRungeKutta",
"Coefficients" -> FehlbergCoefficients, "DifferenceOrder" -> 4,
"EmbeddedDifferenceOrder" -> 5, "StiffnessTest" -> False};
s2 = NDSolve[{D[X[t], t] ==
Subscript[a, 11] X[t] - Subscript[a, 12] X[t]^2 -
Subscript[a, 13] X[t] Y[t] ,
D[Y[t], t] == -Subscript[a, 21] Y[t] - Subscript[a, 22] Y[t]^2 +
Subscript[a, 13] X[t] Y[t],
X[0] == 10, Y[0] == 5}, {X, Y}, {t, 30}, Method -> Fehlberg45]
Plot[Evaluate[{X[t], Y[t]} /. First[s2]], {t, 0, 30},
PlotLegends -> Placed["X[t],Y[t]", Below],
PlotRange -> All]
L3 = Table[{t, s2[t]}, {t, 0, 10}] // TableForm
Question
- The outcome of the values are not giving me what I need as seen in the picture.
- Is it okay to have the same graph or numerical values when using CRK4 and RKF45
L3 = Table[Join[{t}, Through[({X, Y} /. Flatten[s2])[t]]], {t, 0, 10}] // TableForm
. $\endgroup$s2
is not a function, it's a solution of a differential equation. It is a set of rules. $\endgroup$TableForm
should not be included in definitions of variables such asL3
. The wrappers make subsequent use of the variables difficult. Either use parentheses to isolate the definition from the wrapper, e.g.,(L3 = Table[{t, X[t], Y[t]} /. s2[[1]], {t, 0, 10}]) // TableForm
or useTableForm[L3 = Table[{t, X[t], Y[t]} /. s2[[1]], {t, 0, 10}]]
$\endgroup$