I am working with making numerical solvers for a modeling class I am in, and I want to use the internal recursion handling that is built into mathematcia, but there seems to be a problem. NDSolve gives me very rapid results that match up with these, but they are so slow. Euler's method for 20 steps is taking nearly a minute to complete, and Runge-Kutta simply sits there for forever if I go above 6 steps. I know they should be faster, and I could do them as for loops easily enough, but I want to know how to make these work as quickly as they should be. I am sure that I am just missing something.
(*Euler's Method*)
a = 20;
h1 = 2./(a);
f1[t_, x_] := 2 x - 2 t^2 - 3;
t1[k_] := t1[k - 1] + h1;
y1[k_] := y1[k - 1] + h1*f1[t1[k - 1], y1[k - 1]];
t1[0] = 0;
y1[0] = 2;
y1[a]
(*Runge-Kutta*)
b = 6;
h2 = 2/b;
K1[k_] := h2*f2[t2[k], y2[k]];
K2[k_] := h2*f2[t2[k] + 1/2*h2, y2[k] + 1./2*K1[k]];
K3[k_] := h2*f2[t2[k] + 1/2*h2, y2[k] + 1/2*K2[k]];
K4[k_] := h2*f2[t2[k] + h2, y2[k] + K3[k]];
f2[t_, y_] := 2 y - 2 t^2 - 3;
t2[k_] := t2[k - 1] + h2;
y2[k_] := y2[k - 1] + 1/6 (K1[k - 1] + 2*K2[k - 1] + 2*K3[k - 1] + K4[k - 1]);
t2[0] = 0;
y2[0] = 2;
y2[b]