Advertisement
Guest User

Untitled

a guest
Dec 17th, 2014
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. m[x_, y_] = D[f[x, y], x];
  2. n[x_, y_] = D[f[x, y], y];
  3. Field[x_, y_] = {m[x, y], n[x, y]};
  4.  
  5. vectorfieldplot = Table[Vector[gradf[x, y], Tail -> {x, y}, ScaleFactor -> scalefactor], {x, -2, 2, 0.5}, {y, -2, 2, 0.5}];
  6. Show[vectorfieldplot, Axes -> True, AxesLabel -> {"x", "y"}];
  7. {a, b} = {.5, -1};
  8. starterpoint = {a, b};
  9. Clear[x, y, t];
  10. equationx = x'[t] == m[x[t], y[t]];
  11. equationy = y'[t] == n[x[t], y[t]];
  12. starterx = x[0] == a;
  13. startery = y[0] == b;
  14. endtime = 50;
  15. approxsolutions = NDSolve[{equationx, equationy, starterx, startery}, {x[t], y[t]}, {t, 0, endtime}];
  16. Clear[trajectory];
  17. trajectory[t_] = {x[t] /. approxsolutions[[1]], y[t] /. approxsolutions[[1]]};
  18. trajectoryplot = ParametricPlot[trajectory[t], {t, 0, endtime}, PlotStyle -> {{Red, Thickness[0.015]}}];
  19. starterplot = Graphics[{Red, PointSize[0.06], Point[starterpoint]}];
  20. Show[vectorfieldplot, starterplot, trajectoryplot, Axes -> True, AxesLabel -> {"x", "y"}, PlotRange -> All]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement