kill(all)$

example :variation parameter f(x) = tan(x),version 1.0
peter.vlasschaert@gmail.com,03/03/2020

see :website,special, perturbation (theoretical foundation)
==========================================
appendix :perturbation ,linear inhomogeneous diff eq,variation of parameters
peter.vlasschaert@gmail.com,03/03/2020

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

load(lrats)$
load(contrib_ode)$

Mathematical Model :
===============

p1:'diff(y,x,2)+y =tan(x);

representation: general model, see appendix

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

solution: Mathematical Model : y = yh + yp

1e) yh : when  tan(x) =0
==================

p2:subst([tan(x) = 0],p1);

solve :yh
-----------

p2a:ode2(p2,y,x);

p2a1:subst([y=yh],p2a);

set : y1,y2
-------------

p2b1:y1=coeff(rhs(p2a),%k2);
p2b2:y2=coeff(rhs(p2a),%k1);

2e)yp : when tan(x)≠0
================
solve system :equations.

p3:p1;
p3a: a2=1;

solve : yp
------------

p3b:subst([p2b1,p2b2],yp =a(x)*y1+b(x)*y2);

system: equations :yp
=================
find:a(x),b(x)

p3c1:diff(a(x),x)*y1+diff(b(x),x)*y2 = 0;
p3c2:diff(a(x),x)*'diff(y1,x)+diff(b(x),x)*'diff(y2,x) = tan(x)/a2;

input values : system
--------------------------

p3d:[p2b1,p2b2,p3a];
p3d1:subst(p3d,p3c1);
p3d2:subst(p3d,p3c2);

evalution system :ev 'command'

p3e1:ev(p3d1,nouns);
p3e2:ev(p3d2,nouns);

solve :system :{a(x),b(x)}

p3f:solve([p3e1,p3e2],['diff(a(x),x,1),'diff(b(x),x,1)]);

p3f1:flatten(p3f);

find :a(x)
=======

p3f2a:p3f1[1];

p3f12b:integrate(p3f2a,x);

p3f12c:subst([%c1=0],p3f12b);

find :b(x)
=======

p3f3a:p3f1[2];

p3f13b:integrate(p3f3a,x);

p3f13c:subst([%c2=0],p3f13b);

final result :yp
===========
use : p3b

p4:subst([p3f12c,p3f13c],p3b);

final result:Mathematical model
========

p5:y=yh+yp;

p5a:(subst([p4,p2a1],%));

p5b:expand(p5a);

p5c:p5b,logcontract;

p5d:expand(p5c);