Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- m[x_, y_] = D[f[x, y], x];
- n[x_, y_] = D[f[x, y], y];
- Field[x_, y_] = {m[x, y], n[x, y]};
- vectorfieldplot = Table[Vector[gradf[x, y], Tail -> {x, y}, ScaleFactor -> scalefactor], {x, -2, 2, 0.5}, {y, -2, 2, 0.5}];
- Show[vectorfieldplot, Axes -> True, AxesLabel -> {"x", "y"}];
- {a, b} = {.5, -1};
- starterpoint = {a, b};
- Clear[x, y, t];
- equationx = x'[t] == m[x[t], y[t]];
- equationy = y'[t] == n[x[t], y[t]];
- starterx = x[0] == a;
- startery = y[0] == b;
- endtime = 50;
- approxsolutions = NDSolve[{equationx, equationy, starterx, startery}, {x[t], y[t]}, {t, 0, endtime}];
- Clear[trajectory];
- trajectory[t_] = {x[t] /. approxsolutions[[1]], y[t] /. approxsolutions[[1]]};
- trajectoryplot = ParametricPlot[trajectory[t], {t, 0, endtime}, PlotStyle -> {{Red, Thickness[0.015]}}];
- starterplot = Graphics[{Red, PointSize[0.06], Point[starterpoint]}];
- Show[vectorfieldplot, starterplot, trajectoryplot, Axes -> True, AxesLabel -> {"x", "y"}, PlotRange -> All]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement