I want to solve x'=y,y'=6x-y+G,x(0)=1,y(0)=1 with Runge-Kutta Method. Here G lies in [0,1]. I want to get the plot of G versus x. is that possible? May any one help me with that? Here is my code.
ClearAll["Global`*"];
a = 0; b = 1;
x[0] = 1; y[0] = 1;
h = 0.1; n = (b - a)/h;
Do[t[i] = 0.0 + (i)*h, {i, 0, n}]
Do[G[j] = 0.0 + (j)*h, {j, 0, n}]
f[t_, G_,x_, y_] = y; g[t_,G_, x_, y_] = 6*x - y+G;
Do[S1 = f[t[i], G[i], x[i], y[i]]; P1 = g[t[i], G[i], x[i], y[i]];
S2 = f[t[i] + h, G[i] + h, x[i] + h*S1, y[i] + h*P1];
P2 = g[t[i] + h, G[i] + h, x[i] + h*S1, y[i] + h*P1];
S3 = f[t[i] + h/2, G[i] + h/2, x[i] + h*S2/2, y[i] + h*P2/2];
P3 = g[t[i] + h/2, G[i] + h/2, x[i] + h*S2/2, y[i] + h*P2/2];
S4 = f[t[i] + h, G[i] + h, x[i] + h*S3, y[i] + h*P3];
P4 = g[t[i] + h, G[i] + h, x[i] + h*S3, y[i] + h*P3];
x[i + 1] = x[i] + (S1 + 2 S2 + 2 S3 + S4)*h/6;
y[i + 1] = y[i] + (P1 + 2 P2 + 2 P3 + P4)*h/6, {i, 0, k}]
Table[{G[j], x[j]}, {j, 0, k}];