ldedemos.mw

> restart;
 

> with(LinearAlgebra): with(DEtools): with(plots):
 

>
 

> buildsys := proc(mat)
 

> {diff(x(t),t)=mat[1,1]*x(t)+mat[1,2]*y(t), diff(y(t),t)=mat[2,1]*x(t)+mat[2,2]*y(t)};
 

> end;
 

Typesetting:-mprintslash([`:=`(buildsys, proc (mat) {diff(x(t), t) = `+`(`*`(mat[1, 1], `*`(x(t))), `*`(mat[1, 2], `*`(y(t)))), diff(y(t), t) = `+`(`*`(mat[2, 1], `*`(x(t))), `*`(mat[2, 2], `*`(y(t)))...
Typesetting:-mprintslash([`:=`(buildsys, proc (mat) {diff(x(t), t) = `+`(`*`(mat[1, 1], `*`(x(t))), `*`(mat[1, 2], `*`(y(t)))), diff(y(t), t) = `+`(`*`(mat[2, 1], `*`(x(t))), `*`(mat[2, 2], `*`(y(t)))...
Typesetting:-mprintslash([`:=`(buildsys, proc (mat) {diff(x(t), t) = `+`(`*`(mat[1, 1], `*`(x(t))), `*`(mat[1, 2], `*`(y(t)))), diff(y(t), t) = `+`(`*`(mat[2, 1], `*`(x(t))), `*`(mat[2, 2], `*`(y(t)))...
 

> circlepts := proc(numints)
dt := 2*Pi/numints; plist :=[];
for i from 1 to numints do t := (i-1)*dt; plist:=[op(plist), <cos(t),sin(t)>]; od;
return Matrix(plist);
end:
 

 

 

 

Warning, `dt` is implicitly declared local to procedure `circlepts`
Warning, `plist` is implicitly declared local to procedure `circlepts`
Warning, `i` is implicitly declared local to procedure `circlepts`
Warning, `t` is implicitly declared local to procedure `circlepts`
 

> cpts := circlepts(12);
 

Typesetting:-mprintslash([`:=`(cpts, RTABLE(8700000, anything, Matrix, rectangular, Fortran_order, [], 2, 1 .. 2, 1 .. 12))], [Matrix(%id = 8700000)])
 

> mkinitials := proc(ptmat)
[seq([0, ptmat[1,i], ptmat[2,i]], i=1..ColumnDimension(ptmat))];
end;
 

>
 

Typesetting:-mprintslash([`:=`(mkinitials, proc (ptmat) [seq([0, ptmat[1, i], ptmat[2, i]], i = 1 .. LinearAlgebra:-ColumnDimension(ptmat))] end proc)], [proc (ptmat) [seq([0, ptmat[1, i], ptmat[2, i]...
Typesetting:-mprintslash([`:=`(mkinitials, proc (ptmat) [seq([0, ptmat[1, i], ptmat[2, i]], i = 1 .. LinearAlgebra:-ColumnDimension(ptmat))] end proc)], [proc (ptmat) [seq([0, ptmat[1, i], ptmat[2, i]...
Typesetting:-mprintslash([`:=`(mkinitials, proc (ptmat) [seq([0, ptmat[1, i], ptmat[2, i]], i = 1 .. LinearAlgebra:-ColumnDimension(ptmat))] end proc)], [proc (ptmat) [seq([0, ptmat[1, i], ptmat[2, i]...
 

> mkinitials(cpts);
 

[[0, 1, 0], [0, `+`(`*`(`/`(1, 2), `*`(`^`(3, `/`(1, 2))))), `/`(1, 2)], [0, `/`(1, 2), `+`(`*`(`/`(1, 2), `*`(`^`(3, `/`(1, 2)))))], [0, 0, 1], [0, -`/`(1, 2), `+`(`*`(`/`(1, 2), `*`(`^`(3, `/`(1, 2)...
[[0, 1, 0], [0, `+`(`*`(`/`(1, 2), `*`(`^`(3, `/`(1, 2))))), `/`(1, 2)], [0, `/`(1, 2), `+`(`*`(`/`(1, 2), `*`(`^`(3, `/`(1, 2)))))], [0, 0, 1], [0, -`/`(1, 2), `+`(`*`(`/`(1, 2), `*`(`^`(3, `/`(1, 2)...
 

>
 

> P := <<1,-2>|<1,1>>;
 

Typesetting:-mprintslash([`:=`(P, Matrix([[1, 1], [-2, 1]]))], [Matrix(%id = 8871264)])
 

>
 

>
 

>
 

> dmat := DiagonalMatrix([-1/5, -2/5]);
 

Typesetting:-mprintslash([`:=`(dmat, Matrix([[-`/`(1, 5), 0], [0, -`/`(2, 5)]]))], [Matrix(%id = 9301872)])
 

> eqns := buildsys(dmat);
 

Typesetting:-mprintslash([`:=`(eqns, {diff(x(t), t) = `+`(`-`(`*`(`/`(1, 5), `*`(x(t))))), diff(y(t), t) = `+`(`-`(`*`(`/`(2, 5), `*`(y(t)))))})], [{diff(x(t), t) = `+`(`-`(`*`(`/`(1, 5), `*`(x(t)))))...
 

> DEplot(buildsys(dmat), [x(t), y(t)], t=0..10, mkinitials(cpts), animatecurves=true, color=magnitude, linecolor=blue);
 

Plot_2d
 

>
 

>
 

> A := P.dmat.P^(-1);
 

Typesetting:-mprintslash([`:=`(A, Matrix([[-`/`(1, 3), -`/`(1, 15)], [-`/`(2, 15), -`/`(4, 15)]]))], [Matrix(%id = 10399544)])
 

> pcpts := P.cpts
 

 

Warning, inserted missing semicolon at end of statement
Typesetting:-mprintslash([`:=`(pcpts, RTABLE(10236304, anything, Matrix, rectangular, Fortran_order, [], 2, 1 .. 2, 1 .. 12))], [Matrix(%id = 10236304)])
 

> DEplot(buildsys(A), [x(t), y(t)], t=0..10, mkinitials(pcpts), animatecurves=true, color=magnitude, linecolor=blue);
 

Plot_2d
 

>
 

>
 

> dmat := DiagonalMatrix([0.1,0.15]);
 

Typesetting:-mprintslash([`:=`(dmat, Matrix([[.1, 0], [0, .15]]))], [Matrix(%id = 16652536)])
 

> DEplot(buildsys(dmat), [x(t), y(t)], t=0..15, mkinitials(cpts), animatecurves=true, color=magnitude, linecolor=blue);
 

Plot_2d
 

>
 

> A := P.dmat.P^(-1);
 

Typesetting:-mprintslash([`:=`(A, Matrix([[.133333333333333331, 0.166666666666666630e-1], [0.333333333333333259e-1, .116666666666666669]]))], [Matrix(%id = 17096072)])
 

> pcpts := P.cpts;
 

Typesetting:-mprintslash([`:=`(pcpts, RTABLE(11299192, anything, Matrix, rectangular, Fortran_order, [], 2, 1 .. 2, 1 .. 12))], [Matrix(%id = 11299192)])
 

> DEplot(buildsys(A), [x(t), y(t)], t=0..15, mkinitials(pcpts), animatecurves=true, color=magnitude, linecolor=blue);
 

Plot_2d
 

> pf := DEplot(buildsys(A), [x(t), y(t)], t=0..15, mkinitials(pcpts), color=magnitude, linecolor=blue):
 

> p1 := plot([P[1,1]*t, P[2,1]*t, t=-7..7], color=green):
 

> p2 := plot([P[1,2]*t, P[2,2]*t, t=-7..7], color=red):
 

> display([pf,p1,p2]);
 

Plot_2d
 

>
 

>
 

>
 

> dmat := DiagonalMatrix([-0.1,0.04]);
 

Typesetting:-mprintslash([`:=`(dmat, Matrix([[-.1, 0], [0, 0.4e-1]]))], [Matrix(%id = 20243792)])
 

> DEplot(buildsys(dmat), [x(t), y(t)], t=0..15, mkinitials(circlepts(16)), x=-2..2, y=-2..2, animatecurves=true, color=magnitude, linecolor=blue);
 

Plot_2d
 

>
 

> A := P.dmat.P^(-1);
 

Typesetting:-mprintslash([`:=`(A, Matrix([[-0.666666666666666796e-2, 0.466666666666666688e-1], [0.933333333333333376e-1, -0.533333333333333368e-1]]))], [Matrix(%id = 8799104)])
 

> ppts := P.circlepts(16);
 

Typesetting:-mprintslash([`:=`(ppts, RTABLE(16019296, anything, Matrix, rectangular, Fortran_order, [], 2, 1 .. 2, 1 .. 16))], [Matrix(%id = 16019296)])
 

> DEplot(buildsys(A), [x(t), y(t)], t=0..15, mkinitials(ppts), x=-2..2, y=-2..2, animatecurves=true, color=magnitude, linecolor=blue);
 

Plot_2d
 

>
 

>
 

>
 

>
 

> alpha :=1 ; beta := 2; lambda := alpha + beta*I;
 

 

 

Typesetting:-mprintslash([`:=`(alpha, 1)], [1])
Typesetting:-mprintslash([`:=`(beta, 2)], [2])
Typesetting:-mprintslash([`:=`(lambda, `+`(1, `*`(2, `*`(I))))], [`+`(1, `*`(2, `*`(I)))])
 

> Q := copy(P);
 

Typesetting:-mprintslash([`:=`(Q, Matrix([[1, 1], [-2, 1]]))], [Matrix(%id = 16162336)])
 

> M := <<alpha|-beta>, <beta|alpha>>;
 

Typesetting:-mprintslash([`:=`(M, Matrix([[1, -2], [2, 1]]))], [Matrix(%id = 11977176)])
 

> A := Q.M.Q^(-1);
 

Typesetting:-mprintslash([`:=`(A, Matrix([[`/`(1, 3), -`/`(4, 3)], [`/`(10, 3), `/`(5, 3)]]))], [Matrix(%id = 12857064)])
 

> Eigenvectors(A);
 

Typesetting:-mprintslash([Vector[column]([[`+`(1, `*`(2, `*`(I)))], [`+`(1, `-`(`*`(2, `*`(I))))]]), Matrix([[`+`(`-`(`/`(1, 5)), `*`(`/`(3, 5), `*`(I))), `+`(`-`(`/`(1, 5)), `-`(`*`(`/`(3, 5), `*`(I)...
 

> (u,v):=Column(Q, 1..-1);
 

Typesetting:-mprintslash([`:=`(u, v, Vector[column]([[1], [-2]]), Vector[column]([[1], [1]]))], [Vector[column](%id = 6434488), Vector[column](%id = 6430864)])
 

> P:= < u-I*v|u+I*v>;
 

Typesetting:-mprintslash([`:=`(P, Matrix([[`+`(1, `-`(I)), `+`(1, I)], [`+`(`-`(2), `-`(I)), `+`(`-`(2), I)]]))], [Matrix(%id = 7173200)])
 

> P^(-1).A.P;
 

Typesetting:-mprintslash([Matrix([[`+`(1, `*`(2, `*`(I))), 0], [0, `+`(1, `-`(`*`(2, `*`(I))))]])], [Matrix(%id = 9021904)])
 

>
 

> alpha := 0.1; beta := 2;
 

 

Typesetting:-mprintslash([`:=`(alpha, .1)], [.1])
Typesetting:-mprintslash([`:=`(beta, 2)], [2])
 

> M := Matrix([
 

> [alpha, -beta],
 

> [beta, alpha]]);
 

Typesetting:-mprintslash([`:=`(M, Matrix([[.1, -2], [2, .1]]))], [Matrix(%id = 9631064)])
 

>
 

> DEplot(buildsys(M), [x(t),y(t)], t=0..5, [[0, 1, 0]], animatecurves=true, color=magnitude, linecolor=blue,numsteps=1000, numpoints = 505);
 

Plot_2d
 

> A := Q.M.Q^(-1);
 

Typesetting:-mprintslash([`:=`(A, Matrix([[-.566666666666666541, -1.33333333333333326], [3.33333333333333304, .766666666666666496]]))], [Matrix(%id = 14347088)])
 

> apt := A.<1,0>;
 

Typesetting:-mprintslash([`:=`(apt, Vector[column]([[-.566666666666666541], [3.33333333333333304]]))], [Vector[column](%id = 8703032)])
 

> DEplot(buildsys(A), [x(t),y(t)], t=0..5, [[0,apt[1], apt[2]]], animatecurves=true, color=magnitude, linecolor=blue,numsteps=1000, numpoints = 505);
 

Plot_2d
 

>
 

>
 

>
 

>
 

> alpha := -0.1; beta := 2;
 

 

Typesetting:-mprintslash([`:=`(alpha, -.1)], [-.1])
Typesetting:-mprintslash([`:=`(beta, 2)], [2])
 

>
 

> M := Matrix([
 

> [alpha, -beta],
 

> [beta, alpha]]);
 

Typesetting:-mprintslash([`:=`(M, Matrix([[-.1, -2], [2, -.1]]))], [Matrix(%id = 11121440)])
 

>
 

> DEplot(buildsys(M), [x(t),y(t)], t=0..7, [[0, 1, 0]], animatecurves=true, color=magnitude, linecolor=blue,numsteps=1000, numpoints = 505);
 

Plot_2d
 

> A := Q.M.Q^(-1);
 

Typesetting:-mprintslash([`:=`(A, Matrix([[-.766666666666666718, -1.33333333333333326], [3.33333333333333304, .566666666666666541]]))], [Matrix(%id = 11175896)])
 

> apt := A.<1,0>;
 

Typesetting:-mprintslash([`:=`(apt, Vector[column]([[-.766666666666666718], [3.33333333333333304]]))], [Vector[column](%id = 8867592)])
 

> DEplot(buildsys(A), [x(t),y(t)], t=0..7, [[0,apt[1], apt[2]]], animatecurves=true, color=magnitude, linecolor=blue,numsteps=1000, numpoints = 505);
 

Plot_2d
 

>
 

>
 

>
 

>
 

>
 

> alpha := 0; beta := 2;
 

 

Typesetting:-mprintslash([`:=`(alpha, 0)], [0])
Typesetting:-mprintslash([`:=`(beta, 2)], [2])
 

>
 

> M := Matrix([
 

> [alpha, -beta],
 

> [beta, alpha]]);
 

Typesetting:-mprintslash([`:=`(M, Matrix([[0, -2], [2, 0]]))], [Matrix(%id = 14110640)])
 

>
 

> DEplot(buildsys(M), [x(t),y(t)], t=0..4, x=-1.1..1.1, y=-1.1..1.1, [[0, 1, 0]], animatecurves=true, color=magnitude, linecolor=blue,numsteps=1000, numpoints = 505);
 

Plot_2d
 

> A := Q.M.Q^(-1);
 

Typesetting:-mprintslash([`:=`(A, Matrix([[-`/`(2, 3), -`/`(4, 3)], [`/`(10, 3), `/`(2, 3)]]))], [Matrix(%id = 11326016)])
 

> apt := A.<1,0>;
 

Typesetting:-mprintslash([`:=`(apt, Vector[column]([[-`/`(2, 3)], [`/`(10, 3)]]))], [Vector[column](%id = 7962344)])
 

> DEplot(buildsys(A), [x(t),y(t)], t=0..7, [[0,apt[1], apt[2]]],x=-4..4, y=-4..4, animatecurves=true, color=magnitude, linecolor=blue,numsteps=1000, numpoints = 505);
 

Plot_2d
 

>
 

>
 

>
 

>
 

>
 

>
 

> lambda := -0.1;
 

Typesetting:-mprintslash([`:=`(lambda, -.1)], [-.1])
 

> M := Matrix([
 

> [lambda, 1],
 

> [0, lambda]]);
 

Typesetting:-mprintslash([`:=`(M, Matrix([[-.1, 1], [0, -.1]]))], [Matrix(%id = 14800864)])
 

> DEplot(buildsys(M), [x(t), y(t)], t=0..30, mkinitials(cpts), animatecurves=true, color=magnitude, linecolor=blue);
 

Plot_2d
 

> sol := dsolve(buildsys(M), [x(t),y(t)]);
 

Typesetting:-mprintslash([`:=`(sol, {x(t) = `*`(`+`(`*`(_C2, `*`(t)), _C1), `*`(exp(`+`(`-`(`*`(`/`(1, 10), `*`(t))))))), y(t) = `*`(_C2, `*`(exp(`+`(`-`(`*`(`/`(1, 10), `*`(t)))))))})], [{x(t) = `*`(...
 

> subs(sol, y(t)/x(t));
 

`/`(`*`(_C2), `*`(`+`(`*`(_C2, `*`(t)), _C1)))
 

> limit(%, t=infinity);
 

0
 

>
 

> P := copy(Q);
 

Typesetting:-mprintslash([`:=`(P, Matrix([[1, 1], [-2, 1]]))], [Matrix(%id = 12843624)])
 

>
 

>
 

>
 

> A := P.M.P^(-1);
 

Typesetting:-mprintslash([`:=`(A, Matrix([[.566666666666666652, .333333333333333315], [-1.33333333333333326, -.766666666666666607]]))], [Matrix(%id = 20891480)])
 

> apts := P.cpts;
 

Typesetting:-mprintslash([`:=`(apts, RTABLE(14159784, anything, Matrix, rectangular, Fortran_order, [], 2, 1 .. 2, 1 .. 12))], [Matrix(%id = 14159784)])
 

> DEplot(buildsys(A), [x(t), y(t)], t=0..30, mkinitials(apts), animatecurves=true, color=magnitude, linecolor=blue);
 

Plot_2d
 

>
 

>
 

>
 

>
 

>
 

> lambda := 0.2;
 

Typesetting:-mprintslash([`:=`(lambda, .2)], [.2])
 

> M := Matrix([
 

> [lambda, 1],
 

> [0, lambda]]);
 

Typesetting:-mprintslash([`:=`(M, Matrix([[.2, 1], [0, .2]]))], [Matrix(%id = 7760960)])
 

> ippts := Matrix([seq(<i*0.1,-i*0.1/10>, i=-10..10)]);
 

Typesetting:-mprintslash([`:=`(ippts, RTABLE(23915152, anything, Matrix, rectangular, Fortran_order, [], 2, 1 .. 2, 1 .. 21))], [Matrix(%id = 23915152)])
 

> DEplot(buildsys(M), [x(t), y(t)], t=0..10, mkinitials(ippts), animatecurves=true, color=magnitude, linecolor=blue);
 

Plot_2d
 

>
 

>
 

>
 

>
 

> A := P.M.P^(-1);
 

Typesetting:-mprintslash([`:=`(A, Matrix([[.866666666666666585, .333333333333333315], [-1.33333333333333326, -.466666666666666674]]))], [Matrix(%id = 6899208)])
 

> apts := P.ippts;
 

Typesetting:-mprintslash([`:=`(apts, RTABLE(7866880, float[8], Matrix, rectangular, Fortran_order, [], 2, 1 .. 2, 1 .. 21))], [Matrix(%id = 7866880)])
 

> DEplot(buildsys(A), [x(t), y(t)], t=0..10, mkinitials(apts), animatecurves=true, color=magnitude, linecolor=blue);
 

Plot_2d
 

>
 

>
 

>
 

>
 

> lambda := 0;
 

Typesetting:-mprintslash([`:=`(lambda, 0)], [0])
 

> M := Matrix([
 

> [lambda, 1],
 

> [0, lambda]]);
 

Typesetting:-mprintslash([`:=`(M, Matrix([[0, 1], [0, 0]]))], [Matrix(%id = 8415784)])
 

> ippts := Matrix([seq(<i*0.1,-i*0.1/10>, i=-10..10)]);
 

Typesetting:-mprintslash([`:=`(ippts, RTABLE(8412328, anything, Matrix, rectangular, Fortran_order, [], 2, 1 .. 2, 1 .. 21))], [Matrix(%id = 8412328)])
 

> DEplot(buildsys(M), [x(t), y(t)], t=0..10, mkinitials(ippts), animatecurves=true, color=magnitude, linecolor=blue);
 

Plot_2d
 

>
 

> dsolve(buildsys(M), [x(t),y(t)]);
 

{y(t) = _C2, x(t) = `+`(`*`(_C2, `*`(t)), _C1)}
 

>
 

>
 

> A := P.M.P^(-1);
 

Typesetting:-mprintslash([`:=`(A, Matrix([[`/`(2, 3), `/`(1, 3)], [-`/`(4, 3), -`/`(2, 3)]]))], [Matrix(%id = 16132656)])
 

> apts := P.ippts;
 

Typesetting:-mprintslash([`:=`(apts, RTABLE(9295840, float[8], Matrix, rectangular, Fortran_order, [], 2, 1 .. 2, 1 .. 21))], [Matrix(%id = 9295840)])
 

>
 

>
 

>
 

>
 

>
 

>
 

>
 

>
 

>
 

>