pag. 46, #17. solving the initial value problem for a 1st order separable equationyou cannot use dsolve, you should integrate.1-y;int(1/%,y);As y(0)=3, 1-y is negative: we have to change the sign under the argument of the logaritm.-ln(y-1);%=int(x^3,x)+C;sol:=y(x)=solve(%,y);3=subs(x=0,rhs(sol));C=solve(%,C);sol:=subs(%,sol);simplify(%);pag. 54, #14. obtaining the general solution of a 1st order linear equationrestart:The equation is not in standard form. It is imperative that the linear equation be in standard form beforewe attempt to determine the coefficient p of y. If the coefficient ofy' is not one, then p and the resulting integrating factor will beincorrect; and the "solution" will not check. It is also necessarythat the term involving y be on the same side as y' and that all x'sbe on the right hand side.Here is the original differential equation.odiffeq:=x*diff(y(x),x)+3*y(x)+2*x^2=x^3+4*x;To rewrite it in standard form, we subtract 2*x^2 from both sides, then we divide by x. (In thissimple case, it may be easier to retype the equation by hand.)ndiffeq:=diff(y(x),x)+(3*y(x))/x=x^2+4-2*x;The expression p is the coefficient of y, including sign, when theequation is in standard form.p:=3/x;int(p,x);The integrating factor is the exponential of the antiderivative of p.mu:=exp(%);After the standard form equation is multiplied by the integratingfactor, the left hand side is a perfect derivative. Hence, when weintegrate, the left hand side will always be mu*y(x). To find y(x), we need only divide by mu. Note that Maple does not automatically insert a constant ofintegration, so we must do it manually.mu*ndiffeq;expand(%);mu*y(x)=int(rhs(%),x)+c;solve(%,y(x)):
sol:=y(x)=expand(%);Notice that x is different from 0 as we divided from it in one of the previous steps.Checking (in the original differential equation):subs(sol,odiffeq):
simplify(%);pag. 54, #31. discontinuous coefficientThere are two approaches to solve this kind of situations. The 1st one is to consider two different differential equations. We use the 2nd one as dsolve command accepts the piecewise entry, producing a piecewise answer.restart:
P:=piecewise(0<=x and x<=2,1,x>2,3);diffeq:=diff(y(x),x)+P*y(x)=x;inits:=y(0)=1;sol:=dsolve({diffeq,inits},y(x));Notice that the program is computing the backward solution as well, just by putting P(x)=0 for x<0. The backward solution is meaningless fopr us, as our differential problem lives in the halfline [0,+infty).plot(rhs(sol),x=0..5);