\( \DeclareMathOperator{\abs}{abs} \newcommand{\ensuremath}[1]{\mbox{$#1$}} \)
(%i1) kill(all)$
(%i1) load(eigen)$

module 1:intro how to solve system : differential equations. ,  intro
[email protected] , 24/03/2017

IVP = initial value problem  : first order differential equation.
-----------------------------------------------------------------
-----------------------------------------------------------------
menu → Equations → Solve ODE ⇒  'ode2'
-----------------------------------------------------------------
-----------------------------------------------------------------
dx/dt = 2*x
start(= initial) value = x(t=0)= x0 *,' t=0 or t=t0 '
solution : x(t) = x0 e^(2*t)
-----------------------------------------------------------------
rem :( 2 = variable - > a), use 'assume' statement

     p1: dx/dt = a * x;
     assume( a>0);
-----------------------------------------------------------------
-----------------------------------------------------------------

(%i2) p1:ode2('diff(x,t)=2*x,x,t);
\[\tag{p1}\label{p1}x=\mathit{\%{}c}\,{{\%{}e}^{2t}}\]

use * 'see above'

(%i3) p2:ev(p1,%c=x0,t=0);
\[\tag{p2}\label{p2}x=\mathit{x0}\]

rem : part(p2,1) →  x
     part(p2,2) →  x0

solution : differential equations < 'diff(x,t)=2*x >

(%i4) p3:ev(p1,%c=part(p2,2));
\[\tag{p3}\label{p3}x={{\%{}e}^{2t}}\,\mathit{x0}\]

       <system of differential equations>.

       '2' ( e^(2*t)) will be changed in 'matrix' ( e^(matrix*t))

       1e row matrix  → first   differential equation
       2e row matrix  → second  differential equation
       .......................... etc

       system  : vector 1 = matrix * vector 2

first example :( matrix = '2 by 2' ) system of differential equations. 'intro'
----------------------------------------------------------------------
----------------------------------------------------------------------
first part  ⇒ : principles
            1e) find : eigenvalues.
            2e) find : eigenvector.
second part ⇒ : build matrix 'eigenvectors' ( example ' 3 by 3  ' matrix )
            1e) build matrix
            2e) find : invers of the build matrix
third part  ⇒ : build exponential matrix ' see above '
rem:         < characteristic polynomial >,<unit eigenvectors>
rem :        < multiplicities > ' eigenvalues '

first part ⇒

principles '2 by 2' ,'3 by 3'

(%i5) kill(all);
\[\tag{\%{}o0}\label{o0} \mathit{done}\]
(%i2) ps1:'diff(x[1],t)=-1/2*x[1]+x[2];
ps2:'diff(x[2],t)=0*x[1]-2*x[2];
\[\tag{ps1}\label{ps1}\frac{d}{dt}{{x}_{1}}={{x}_{2}}-\frac{{{x}_{1}}}{2}\] \[\tag{ps2}\label{ps2}\frac{d}{dt}{{x}_{2}}=-2{{x}_{2}}\]
(%i3) p4: matrix ([-.5, 1], [0, -2]);
\[\tag{p4}\label{p4}\begin{pmatrix}-0.5 & 1\\ 0 & -2\end{pmatrix}\]

calculation : eigenvalues  '2 by 2' matrix

(%i4) p5:eigenvalues(p4);
\[\mbox{}\\\mbox{rat: replaced -0.5 by -1/2 = -0.5}\] \[\tag{p5}\label{p5}[[-\frac{1}{2},-2],[1,1]]\]
(%i6) p6:lambda[1]=part(p5,1,1);
p7:lambda[2]=part(p5,1,2);
\[\tag{p6}\label{p6}{{\mathit{lambda}}_{1}}=-\frac{1}{2}\] \[\tag{p7}\label{p7}{{\mathit{lambda}}_{2}}=-2\]

calculation : eigenvector '2 by 2' matrix

(%i7) p8:eigenvectors(p4);
\[\mbox{}\\\mbox{rat: replaced -0.5 by -1/2 = -0.5}\] \[\tag{p8}\label{p8}[[[-\frac{1}{2},-2],[1,1]],[[[1,0]],[[1,-\frac{3}{2}]]]]\]
(%i9) p9:p8[2][1][1];
p10:p8[2][2][1];
\[\tag{p9}\label{p9}[1,0]\] \[\tag{p10}\label{p10}[1,-\frac{3}{2}]\]
(%i10) p11:matrix([1,3,2],[3,-5,6],[2,6,4]);
\[\tag{p11}\label{p11}\begin{pmatrix}1 & 3 & 2\\ 3 & -5 & 6\\ 2 & 6 & 4\end{pmatrix}\]
(%i11) p12:eigenvectors(p11);
\[\tag{p12}\label{p12}[[[-\sqrt{70},\sqrt{70},0],[1,1,1]],[[[1,-\frac{\sqrt{70}+5}{3},2]],[[1,\frac{\sqrt{70}-5}{3},2]],[[1,0,-\frac{1}{2}]]]]\]

three eigenvectors  '3 by 3' matrix ' p11 '

1e part : p12    'eigenvalues'

p13 ' eigenvalues                       '
p14 ' multiplicities of the eigenvalues '

(%i13) p13:p12[1][1];
p14:p12[1][2];
\[\tag{p13}\label{p13}[-\sqrt{70},\sqrt{70},0]\] \[\tag{p14}\label{p14}[1,1,1]\]

2e part : p15,p16,p17    'eigenvectors'

(%i16) p15:p12[2][1][1];
p16:p12[2][2][1];
p17:p12[2][3][1];
\[\tag{p15}\label{p15}[1,-\frac{\sqrt{70}+5}{3},2]\] \[\tag{p16}\label{p16}[1,\frac{\sqrt{70}-5}{3},2]\] \[\tag{p17}\label{p17}[1,0,-\frac{1}{2}]\]

second part ⇒

1e) build matrix 'eigenvectors'

(%i17) p18:transpose(matrix(p15,p16,p17));
\[\tag{p18}\label{p18}\begin{pmatrix}1 & 1 & 1\\ -\frac{\sqrt{70}+5}{3} & \frac{\sqrt{70}-5}{3} & 0\\ 2 & 2 & -\frac{1}{2}\end{pmatrix}\]

2e) find : invers of the build matrix 'p18'

(%i18) p19:invert(p18);
\[\tag{p19}\label{p19}\begin{pmatrix}-\frac{\sqrt{70}-5}{6\left( -\frac{5\left( \sqrt{70}+5\right) }{6}-\frac{5\left( \sqrt{70}-5\right) }{6}\right) } & \frac{5}{2\left( -\frac{5\left( \sqrt{70}+5\right) }{6}-\frac{5\left( \sqrt{70}-5\right) }{6}\right) } & -\frac{\sqrt{70}-5}{3\left( -\frac{5\left( \sqrt{70}+5\right) }{6}-\frac{5\left( \sqrt{70}-5\right) }{6}\right) }\\ -\frac{\sqrt{70}+5}{6\left( -\frac{5\left( \sqrt{70}+5\right) }{6}-\frac{5\left( \sqrt{70}-5\right) }{6}\right) } & -\frac{5}{2\left( -\frac{5\left( \sqrt{70}+5\right) }{6}-\frac{5\left( \sqrt{70}-5\right) }{6}\right) } & -\frac{\sqrt{70}+5}{3\left( -\frac{5\left( \sqrt{70}+5\right) }{6}-\frac{5\left( \sqrt{70}-5\right) }{6}\right) }\\ \frac{-\frac{2\left( \sqrt{70}+5\right) }{3}-\frac{2\left( \sqrt{70}-5\right) }{3}}{-\frac{5\left( \sqrt{70}+5\right) }{6}-\frac{5\left( \sqrt{70}-5\right) }{6}} & 0 & \frac{\frac{\sqrt{70}+5}{3}+\frac{\sqrt{70}-5}{3}}{-\frac{5\left( \sqrt{70}+5\right) }{6}-\frac{5\left( \sqrt{70}-5\right) }{6}}\end{pmatrix}\]

third part ⇒

build exponential matrix = p22  ' see above ',use p13

(%i19) p21:diagmatrix(3,1);
\[\tag{p21}\label{p21}\begin{pmatrix}1 & 0 & 0\\ 0 & 1 & 0\\ 0 & 0 & 1\end{pmatrix}\]
(%i20)  for i:1 thru 3 do
   p21[i][i]:exp^(float(p13[i])*t);
\[\tag{\%{}o20}\label{o20} \mathit{done}\]
(%i21) p22:p21;
\[\tag{p22}\label{p22}\begin{pmatrix}\frac{1}{{{\mathit{exp}}^{8.366600265340756t}}} & 0 & 0\\ 0 & {{\mathit{exp}}^{8.366600265340756t}} & 0\\ 0 & 0 & 1.0\end{pmatrix}\]
(%i22) p23:float(p18*p22*p19);
\[\tag{p23}\label{p23}\begin{pmatrix}\frac{0.04023856953328032}{{{\mathit{exp}}^{8.366600265340756t}}} & 0.0 & 0.0\\ 0.0 & 0.2011928476664016{{\mathit{exp}}^{8.366600265340756t}} & 0.0\\ 0.0 & 0.0 & 0.2\end{pmatrix}\]

rem : < characteristic polynomial > , p11 ⇒ find ' lambda=eigenvalues '

statement 'charpoly(matrix)'

(%i23) p24:factor(charpoly(p11,lambda));
\[\tag{p24}\label{p24}-\mathit{lambda}\,\left( {{\mathit{lambda}}^{2}}-70\right) \]
(%i24) p25:allroots(p24);
\[\tag{p25}\label{p25}[\mathit{lambda}=0.0,\mathit{lambda}=-8.366600265340756,\mathit{lambda}=8.366600265340756]\]

the three values :' same : from p13 '

(%i27) p26:p25[1];
p27:p25[2];
p28:p25[3];
\[\tag{p26}\label{p26}\mathit{lambda}=0.0\] \[\tag{p27}\label{p27}\mathit{lambda}=-8.366600265340756\] \[\tag{p28}\label{p28}\mathit{lambda}=8.366600265340756\]

'number' of eigenvalues ⇒ same as dimension of the ( 'matrix' = ' 3 by 3 ') = 3
see : p25

<unit eigenvectors from matrix> 'p11'
statement 'uniteigenvectors(matrix)'

(%i28) p29:float(uniteigenvectors(p11));
\[\tag{p29}\label{p29}[[[-8.366600265340756,8.366600265340756,0.0],[1.0,1.0,1.0]],[[[0.200595537171893,-0.8937601201293323,0.4011910743437861]],[[0.3997016768375131,0.4485452570994388,0.7994033536750261]],[[0.8944271909999159,0.0,-0.4472135954999579]]]]\]

rem : < multiplicities > ' eigenvalues '

(%i29) M1 : matrix ([3,0,0,0], [0,2,0,0],[0,0,3,0],[0,0,0,1]);
\[\tag{M1}\label{M1}\begin{pmatrix}3 & 0 & 0 & 0\\ 0 & 2 & 0 & 0\\ 0 & 0 & 3 & 0\\ 0 & 0 & 0 & 1\end{pmatrix}\]
(%i30) [vals, vecs] : eigenvectors (M1);
\[\tag{\%{}o30}\label{o30} [[[1,2,3],[1,1,2]],[[[0,0,0,1]],[[0,1,0,0]],[[1,0,0,0],[0,0,1,0]]]]\]

1e) vals  ⇒ eigenvalues : same 'eigenvalues'
-----------------------------------------------------
first  part ' vals ' = values
second part ' vals ' = multiplicities from first part
example : value = 3, 2 times .
example : sum part 2 = dimension of matrix = 1+1+2=4 'M1'
          ' 4 by 4 '
-----------------------------------------------------
2e) vecs  ⇒ eigenvectors

(%i32) vals;
vecs;
\[\tag{\%{}o31}\label{o31} [[1,2,3],[1,1,2]]\] \[\tag{\%{}o32}\label{o32} [[[0,0,0,1]],[[0,1,0,0]],[[1,0,0,0],[0,0,1,0]]]\]

module 1:
statements:  ode2,uniteigenvectors,eigenvalues,charpoly,diagmatrix,invert,matrix,allroots,transpose.
new construction 'statement': '[vals, vecs] : eigenvectors (M1);'


Created with wxMaxima.