# How to extract the numerical values in the tables

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

1. The outcome of the values are not giving me what I need as seen in the picture.
2. Is it okay to have the same graph or numerical values when using CRK4 and RKF45
• Please explain more clearly just what you problems are. By the way, use L3 = Table[Join[{t}, Through[({X, Y} /. Flatten[s2])[t]]], {t, 0, 10}] // TableForm. Commented Sep 23, 2021 at 4:34
• @bbgodfrey Thanks for the code. With regards to the problem, I am comparing RK4 and RKF45 hoping to have a better approximation with RKF45 but it seems to me both numerical approximations gives me the same values. Is this correct or something is wrong with my computation? Commented Sep 23, 2021 at 5:02
• There is a problem with your last line. s2 is not a function, it's a solution of a differential equation. It is a set of rules. Commented Sep 23, 2021 at 8:57
• As a general rule, wrappers such as TableForm should not be included in definitions of variables such as L3. 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 use TableForm[L3 = Table[{t, X[t], Y[t]} /. s2[[1]], {t, 0, 10}]] Commented Sep 23, 2021 at 14:36