Variation of parameters for ODE system

clearvars

Example:

Find fundamental set of solutions for homogeneous problem

Find eigenvalues and eigenvectors of matrix A. Find a fundamental set of solutions
See the class of April 10 for details. Here we use dsolve for the homogeneous problem:
A = sym([1 2; 4 3]);
syms y(t) [2 1]
syms C1 C2
sol = dsolve(diff(y)==A*y);
ysol = subs(y(t),sol)
ysol = 
Y1 = subs(ysol,{C1,C2},{1,0})
Y1 = 
Y2 = subs(ysol,{C1,C2},{0,1})
Y2 = 
Psi = [Y1,Y2]
Psi = 

Find by solving the linear system

f = [exp(-t);1]
f = 
Let , this is the solution of the linear system :
w = Psi\f % solve linear system Psi w = f
w = 
With the inverse matrix
inv(Psi)
ans = 
we can write the solution as
w = inv(Psi)*f
w = 

Take the antiderivative to get

u = int(w,t)
u = 

We obtain the particular solution

Y = expand(Psi*u)
Y = 

For comparison: Solve the inhomogeneous ODE with dsolve

sol = dsolve(diff(y)==A*y+f);
ysol = expand( subs(y(t),sol) )
ysol = 
We get a particular solution by plugging in :
Y = expand( subs(ysol,{C1,C2},{0,0}) )
Y = 
This is the same particular solution we obtained with variation of parameters above.