Kernel: SageMath 9.7

C30 Linear Systems Part 6

Linear Systems Review

Nonhomogeneous Linear Systems

Problem: [xy]=[5313][xy]+[sin(t)0]\begin{bmatrix} x' \\ y' \end{bmatrix} = \begin{bmatrix*}[r] -5 & 3 \\ 1 & -3 \end{bmatrix*} \begin{bmatrix} x \\ y \end{bmatrix} + \begin{bmatrix} \sin(t) \\ 0 \end{bmatrix} .

var('a b c d e f g h') solve([-c == -5*a + 3*b + 1, -d == a - 3*b, a == -5*c + 3*d, b == c - 3*d, 0 == -5*e + 3*f, 0 == e - 3*f + 1, e == -5*g + 3*h, f == g - 3*h], [a, b, c, d, e, f, g, h])
var('t') x = function('x')(t) y = function('y')(t) de1 = diff(x, t) == -5*x + 3*y + sin(t) de2 = diff(y, t) == x - 3*y gsoln = desolve_system([de1, de2], [x,y], ivar = t); show(gsoln)
ssoln = desolve_system([de1, de2], [x,y], ivar = t, ics = (0, 0, 0)) xsoln(t) = ssoln[0].rhs() ysoln(t) = ssoln[1].rhs() parametric_plot([xsoln, ysoln], (0,10))
plot([xsoln, ysoln], (0,10))

Double Harmonic Oscillator

Calculate the eigenvalues and eigenvectors.

c1 = 0; c2 = 0; k1 = 2; k2 = 1; m1 = 2; m2 = 1 A = matrix([[0, 1, 0, 0],[-(k1+k2)/m1, -c1/m1, k2/m1, 0], [0, 0, 0, 1], [k2/m2, 0, -k2/m2, -c1/m2]]); show(A) show(A.eigenspaces_right())

Find the General Solution

c1 = 0; c2 = 0; k1 = 2; k2 = 1; m1 = 2; m2 = 1 var('t') w1 = function('w1')(t) w2 = function('w2')(t) w3 = function('w3')(t) w4 = function('w4')(t) de1 = diff(w1, t) == w2 de2 = diff(w2, t) == -(k1+k2)/m1*w1 - c1/m1*w2 + k2/m1*w3 de3 = diff(w3, t) == w4 de4 = diff(w4, t) == k2/m2*w1 - k2/m2*w3 - c1/m2*w4 sol = desolve_system([de1, de2, de3, de4], vars = [w1, w2, w3, w4], ivar = t) w1sol(t) = sol[0].rhs(); show(w1sol(t)) w2sol(t) = sol[1].rhs(); show(w2sol(t)) w3sol(t) = sol[2].rhs(); show(w3sol(t)) w4sol(t) = sol[3].rhs(); show(w4sol(t))

Find a specific solution