kill(all)$

appendix :perturbation ,linear inhomogeneous diff eq,variation of parameters
peter.vlasschaert@gmail.com,03/03/2020

load packages
===========

load(lrats)$
load(contrib_ode)$

general problem :
---------------------
y=y(x) ; a2,a1,a0 are constants 

p1:a2*'diff(y,x,2)+a1*'diff(y,x)+a0*y = f(x);

1e) part (h)omogeneous solution.= yh
----------------------------------------------

p1a:lhs(p1) =0;
p1b:a2*r^2+a1*r+a0 = 0;
p1c:solve(p1b,r);

p1d:[r1=rhs(p1c[1]),r2=rhs(p1c[2])];

p1e:yh = c1*exp(r1*x)+c2*exp(r2*x);

p1f:subst(p1d,p1e);

p1g:yh= y1*c1+y2*c2;

find coef: c1,c2

p1ga:y1=coeff(rhs(p1f),c1,1);
p1gb:y2=coeff(rhs(p1f),c2,1);

2e) part in(h)omogeneous solution.= yp
------------------------------------------------

depends(y1,x,y2,x);

p2:yp=a(x)*y1+b(x)*y2;

p2a:'diff(yp,x,1) = diff(rhs(p2),x);

1e) condition:implimented
===================

p2b1:part(rhs(p2a),2)+part(rhs(p2a),4)  = 0;

 ==================

result :'diff(yp,x,1)
----------------------

p2b2:lratsubst([p2b1],p2a);

result :'diff(yp,x,2)
----------------------

p2b3:'diff(yp,x,2)=diff(rhs(p2b2),x,1);

insert : orginal equation

p2c:a2*rhs(p2b3)+a1*rhs(p2b2)+a0*rhs(p2) =rhs(p1);

p2c1:expand(p2c);

find coef :a(x)
==========
see: y1,p1c

p3a:ratcoef(lhs(p2c1),a(x));

find coef :b(x)
==========
see : y2,p1c

p3b:ratcoef(lhs(p2c1),b(x));

p2c3:m=a(x)*p3a+b(x)*p3b;

p2c4:rhs(p2c3) =0;

2e) condition:implimented
===================
use : p2c1

p3:lratsubst([p2c4],p2c1);

p3a:expand(p3/a2);

system : two equtions (both =conditions)
=============================

p4a:p2b1;
p4b:p3a ;

see :https://en.wikipedia.org/wiki/Wronskian

def :Wronskian
===========

p4:coefmatrix([p4a,p4b],['diff(a(x),x,1),'diff(b(x),x,1)]);

def :augmented Wronskian
====================

p4c:augcoefmatrix([p4a,p4b],['diff(a(x),x,1),'diff(b(x),x,1)]);

how to solve: eq'p4a & p4b'
====================
same : be used 'flatten' to remove to get = []

p5:solve([p4a,p4b],['diff(a(x),x,1),'diff(b(x),x,1)])[1];

to find a(x),b(x)

p5a:p5[1];
p5b:p5[2];

p5a1:subst([0=0],integrate(p5a,x));
p5b1:subst([0=0],integrate(p5b,x));

rem : integration interval , %c1 =%c2 = 0,between some limits , h1≤ x ≤h2

p5c:[p1ga,p1gb];

general solution :y=yh+yp
===================
yh = homogeneous solution
yp = particular solution

p6:y=rhs(p1g)+rhs(p2);