kill(all)$

maxima :'see truebasic :code', vectorfield2d with trajectory,version 1.0
peter.vlasschaert@gmail.com,11/10/2020

ref:truebasic
vector field 2d : with trajectory , version 1.0

load(draw)$

w:0.05$
a:2$
b:-1$
c:1$
d:4$
p:[]$
for x:-5 thru 5 step .5 do(
for y:-5 thru 5 step .5  
 do(
 dx : a*x+b*y,
 dy : c*x +d*y,
    ds:sqrt((dx)^2+(dy)^2),
 if ds > 0 then      
    p:ev(endcons([[x-w*dx/ds,y-w*dy/ds],
    [x+w*dx/ds,y+w*dy/ds]][1],p),nouns)            
    )       
 )$          

p$

length(p);

a) vectorfield 2d
============

wxdraw2d(
color = red,
points(p)     
),wxplot_size=[600,600];

m:[]$
nu:120$
xx1:makelist(0,i,1,nu)$
yy1:makelist(0,i,1,nu)$
xx1[1]:0.01$
yy1[1]:0.01$
for k:1 thru nu-1 do
       (
    dx0 : ev(float(a*xx1[k]+b*yy1[k]),nouns),
    dy0 : ev(float(c*xx1[k]+d*yy1[k]),nouns),
    ds0 : (dx0)^2+(dy0)^2,
    xx1[k+1] : xx1[k] + w*dx0/(ds0)^(1/2),
    yy1[k+1] : yy1[k] + w*dy0/(ds0)^(1/2),
     m:endcons([[xx1[k],yy1[k]],[xx1[k+1],yy1[k+1]]][1],m),
    xx1[k]:xx1[k+1],
    yy1[k]:yy1[k+1]
       )$
m$

b) vectorfield 2d + trajectory
======================

wxdraw2d(
color = red,
point_size = 1.5,    
points(p),
color = blue,
points_joined=true,      
points(m)     
),wxplot_size=[1000,1000];