# SECTION 4.5# Example 1 de := diff(y(t),t,t) + 3*diff(y(t),t) + 2*y(t) = f;y1 := 3*t/2 - 9/4;subs(y(t) = y1,de);expand(%);y2 := exp(3*t)/2;subs(y(t) = y2,de);expand(%);yp := A*y1 + B*y2;subs(y(t) = yp, f = 3*t + 10*exp(3*t),de);expand(%);eq1 := 3*A = 3; eq2 := 10*B = 10;solve({eq1,eq2},{A,B});subs(%,yp);subs(y(t) = yp, f = -9*t + 20*exp(3*t),de);expand(%);eq1 := 3*A = -9; eq2 := 10*B = 20;solve({eq1,eq2},{A,B});
subs(%,yp);
# Example 2ysol := t^2 + c1*exp(t) + c2*exp(-t);subs(t=0,ysol);eq1 := % = 1;diff(ysol,t);subs(t=0,%);eq2 := simplify(%) = 0;solve({eq1,eq2},{c1,c2});subs(%,ysol);# Example 3de := diff(y(t),t,t) + 2*diff(y(t),t) + 2*y(t) = 5*sin(t) + 5*cos(t);yp := A*sin(t) + B*cos(t);subs(y(t) = yp,de);expand(%);eq1 := A - 2*B = 5;eq2 := B + 2*A = 5;solve({eq1,eq2},{A,B});subs(%,yp);yp := %;ysol := exp(-t)*(c1*cos(t)+c2*sin(t)) + yp;subs(t=0,ysol);eq1 := simplify(%) = 1;diff(ysol,t);subs(t=0,%);eq2 := simplify(%) = 2;solve({eq1,eq2},{c1,c2});subs(%,ysol);# Solution using dsolve:dsolve(de);dsolve({de,y(0)=1,D(y)(0)=2});# Example 4de := diff(y(t),t,t) - y(t) = 8*t*exp(t) + 2*exp(t);yp := t*(A1*t + A0)*exp(t);subs(y(t) = yp,de);expand(%);%/exp(t);eq := simplify(%);subs(t=0,%);eq1 := %;diff(eq,t);eq2 := %;solve({eq1,eq2},{A0,A1});subs(%,yp);# Example 5de := diff(y(t),t,t) + 2*diff(y(t),t) + 2*y(t) = 5*exp(-t)*sin(t) + 5*t^3*exp(-t)*cos(t);P := r^2 + 2*r + 2 = 0;solve(P,r);dsolve(de);# Is the above solution consistent with the form of yp given in the text? # Can some terms in the above solution be combined with terms of the homgeneous solution, ie, terms # with _C1 and _C2? Is the form of yp unique? # Example 6de := diff(y(t),t,t,t) + 2*diff(y(t),t,t) + diff(y(t),t) = 5*exp(-t)*sin(t) + 3 + 7*t*exp(-t);dsolve(de);