Differential Equations
Here is a fieldplot for a system of ODEs including a solution curve through a specified point.
> DEtools[DEplot]([diff(x(t),t)=-x(t)+3*y(t),diff(y(t),t)=2*x(t)+y(t)],[x(t),y(t)],t=-2..2,[[x(0)=2,y(0)=1]],x(t)=-6..6,y(t)=-6..6,linecolor=[blue],arrows=SMALL);
Here is the exact solution.
> F:=diffsolve({diff(x(t),t)=-x(t)+3*y(t),diff(y(t),t)=2*x(t)+y(t),x(0)=2,y(0)=1},{x(t),y(t)}):
Maple found the exact solution. Solutions for the the following dependent variables have been obtained. x y For example to access the solution for x use NameYouGaveResult[x]
> F[x];
> F[y];
Here we find the solution to the system by a classic Euler method.
> G:=diffsolve({diff(x(t),t)=-x(t)+3*y(t),diff(y(t),t)=2*x(t)+y(t),x(0)=2,y(0)=1},{x(t),y(t)},type=numeric,method=classical[foreuler],output=listprocedure):
Maple found the solution numerically. It has been returned as several procedures. Solutions for the the following dependent variables have been obtained. y x For example to access the solution for y use NameYouGaveResult[y](value of indepvar) 'NameYouGaveResult[y](indepvar)' The use of the single quotes is required with table of values, limit table, and plot in MenuMaple.
This table allows us to compare the numerical solution for x (obtained by euler's method) with the exact solution for x.
> valutable(['G[x](t)',F[x]],t=-2..2,'step'=0.5);
t funct1(t) funct2(t) ----------------------------------------------- -2. 155.6142317 161.1079203 -1.500000000 41.10635006 42.93490605 -1.000000000 10.92754531 11.51486948 -.500000000 3.161903258 3.361431313 0 2. 2. .500000000 4.639261038 4.679708443 1.000000000 16.52589834 16.81509480 1.500000000 61.31027044 62.92655517 2.000000000 228.1317280 236.1855173