This is a homework problem. I am to plot the directional field of the ode y' = x*y/2 using for loops and or procs. I have the following code:
X := [seq(.1*x, x = -20 .. 20)];
Y := [seq(y, y = -2 .. 2, .1)];
P := Array([seq(0, x = 0 .. 41^2-1)]);
with(plots);
for k to 41 do for j to 41 do
slope := (1/2)*X[k]*Y[j];
Xp := [X[k], X[k]+.1]; Yp := [Y[j], Y[j]+0.1*slope];
P[41*(k-1)+j] := plot(Xp, Yp) end do end do;
display(P);
and get something really awful looking which isn't right.I understand it a lot of plots and would be easier to use detools but as stated it's for homework. I get something like this: https://i.sstatic.net/UArMP.png
You can see why the display(P)
looks wrong if you do display(P[1..2])
- it is a "window of plot windows".
You need to tell Maple that P is not one object but that the display should be of 1681 plots, e.g. with the sequence functional.
display(seq(P[i], i = 1..numelems(P)));