### 2.53.1 Solving differential equations : `desolve deSolve
dsolve`

`desolve` (or `deSolve`) can solve :

- linear differential equations with constant coefficients,
- first order linear differential equations,
- first order differential equations without y,
- first order differential equations without x,
- first order differential equations with separated variables,
- first order homogeneous differential equations (y′=F(y/x)),
- first order differential equations with integrating factor,
- first order Bernoulli differential equations (a(x)y′+b(x)y=c(x)yn),
- first order Clairaut differential equations (y=x*y′+f(y′)).

`desolve` takes as arguments :

- if the independant variable is the current variable (here supposed to be x),
  - the differential equation (or the list of the differential equation and of the initial conditions)
  - the unknown (usually `y`).
  In the differential equation, the function y is denoted by y, it’s first derivative y ′ is denoted by `y′`, and it’s second derivative y′′ is written `y″`.
  For example `desolve(y’’+2*y’+y,y)` or
  `desolve([y’’+2*y’+y,y(0)=1,y’(0)=0],y)`.
- if the independant variable is not the current variable, for example t instead of x,
  - the differential equation (or the list of the differential equation and of the initial conditions),
  - the variable, e.g. `t`
  - the unknown as a variable `y` or as a function `y(t)`.
  In the differential equation, the function y is denoted by y(t), it’s derivative y ′ is denoted by `diff(y(t),t)`, and it’s second derivative y′′ is denoted by `diff(y(t),t$2)`.
  For example :
  `desolve(diff(y(t),t$2)+2*diff(y(t),t)+y(t),y(t))`; or
  `desolve(diff(y(t),t$2)+2*diff(y(t),t)+y(t),t,y)`; and

      desolve([diff(y(t),t$2)+2*diff(y(t),t)+y(t),
               y(0)=1,y'(0)=0],y(t)); or
      desolve([diff(y(t),t$2)+2*diff(y(t),t)+y(t),
               y(0)=1,y'(0)=0],t,y);

If there is no initial conditions (or one initial condition for a second order equation), `desolve` returns the general solution in terms of constants of integration `c_0, c_1`, where `y(0)=c_0` and `y’(0)=c_1`, or a list of solutions.
Examples

- Examples of second linear differential equations with constant coefficients.
  1. Solve :

     y″+y=cos(x)

     Input (typing twice prime for `y’’`):
     `desolve(y’’+y=cos(x),y)`
     or input :
     `desolve((diff(diff(y))+y)=(cos(x)),y)`
     Output :
     `c_0*cos(x)+(x+2*c_1)*sin(x)/2`
     `c_0, c_1` are the constants of integration : `y(0)=c_0` and `y’(0)=c_1`.
     If the variable is not `x` but `t`, input :
     `desolve(derive(derive(y(t),t),t)+y(t)=cos(t),t,y)`
     Output :
     `c_0*cos(t)+(t+2*c_1)/2*sin(t)`
     `c_0, c_1` are the constants of integration : `y(0)=c_0` and `y’(0)=c_1`.
  2. Solve :

     y″+y=cos(x), y(0)=1

     Input :
     `desolve([y’’+y=cos(x),y(0)=1],y)`
     Output :
     `[cos(x)+(x+2*c_1)/2*sin(x)]`
     the components of this vector are solutions (here there is just one component, so we have just one solution depending of the constant `c_1`).
  3. Solve :

     y″+y=cos(x) (y(0))2=1

     Input :
     `desolve([y’’+y=cos(x),y(0)```^```2=1],y)`
     Output :
     `[-cos(x)+(x+2*c_1)/2*sin(x),cos(x)+(x+2*c_1)/2*sin(x)]`
     each component of this list is a solution, we have two solutions depending on the constant `c_1` (y′(0)=c1) and corresponding to y(0)=1 and to y(0)=−1.
  4. Solve :

     y″+y=cos(x), (y(0))2=1 y′(0)=1

     Input :
     `desolve([y’’+y=cos(x),y(0)```^```2=1,y’(0)=1],y)`
     Output :
     `[-cos(x)+(x+2)/2*sin(x),cos(x)+(x+2)/2*sin(x)]`
     each component of this list is a solutions (we have two solutions).
  5. Solve :

     y″+2y′+y=0

     Input :
     `desolve(y’’+2*y’+y=0,y)`
     Output :
     `(x*c_0+x*c_1+c_0)*exp(-x)`
     the solution depends of 2 constants of integration : `c_0, c_1` (`y(0)=c_0` and `y’(0)=c_1`).
  6. Solve :

     y″−6y′+9y=xe3x

     Input:
     `desolve(y’’-6*y’+9*y=(x*exp(3*x),y)`
     Output :
     `(x```^```3+(-(18*x))*c_0+6*x*c_1+6*c_0)*1/6*exp(3*x)`
     the solution depends on 2 constants of integration : `c_0, c_1` (`y(0)=c_0` and `y’(0)=c_1`).
- Examples of first order linear differential equations.
  1. Solve :

     xy′+y−3x2=0

     Input :
     `desolve(x*y’+y-3*x```^```2,y)`
     Output :
     `(3*1/3*x```^```3+c_0)/x`
  2. Solve :

     y′+x*y=0, y(0)=1

     Input :
     `desolve([y’+x*y=0, y(0)=1]),y)`
     or :
     `desolve((y’+x*y=0) && (y(0)=1),y)`
     Output :
     `[1/(exp(1/2*x```^```2))]`
  3. Solve :

     x(x2−1)y′+2y=0

     Input :
     `desolve(x*(x```^```2-1)*y’+2*y=0,y)`
     Output :
     `(c_0)/((x```^```2-1)/(x```^```2))`
  4. Solve :

     x(x2−1)y′+2y=x2

     Input :
     `desolve(x*(x```^```2-1)*y’+2*y=x```^```2,y)`
     Output :
     `(ln(x)+c_0)/((x```^```2-1)/(x```^```2))`
  5. If the variable is t instead of x, for example :

     t(t2−1)y′(t)+2y(t)=t2

     Input :
     `desolve(t*(t```^```2-1)*diff(y(t),t)+2*y(t)=(t```^```2),y(t))`
     Output :
     `(ln(t)+c_0)/((t```^```2-1)/(t```^```2))`
  6. Solve :

     x(x2−1)y′+2y=x2,y(2)=0

     Input :
     `desolve([x*(x```^```2-1)*y’+2*y=x```^```2,y(0)=1],y)`
     Output :
     `[(ln(x)-ln(2))*1/(x```^```2-1)*x```^```2]`
  7. Solve :

     √ |
     1+x2
     | y′−x−y= | √ |
     1+x2

     Input :
     `desolve(y’*sqrt(1+x```^```2)-x-y-sqrt(1+x```^```2),y)`
     Output :
     `(-c_0+ln(sqrt(x```^```2+1)-x))/(x-sqrt(x```^```2+1))`
- Examples of first differential equations with separated variables.
  1. Solve :

     y′=2 | √ |
     y

     Input :
     `desolve(y’=2*sqrt(y),y)`
     Output :
     `[x```^```2+-2*x*c_0+c_0```^```2]`
  2. Solve :

     xy′ln(x)−y(3ln(x)+1)=0

     Input :
     `desolve(x*y’*ln(x)-(3*ln(x)+1)*y,y)`
     Output :
     `c_0*x```^```3*ln(x)`
- Examples of Bernoulli differential equations a(x)y′+b(x)y=c(x)yn where n is a real constant.
  The method used is to divide the equation by yn, so that it becomes a first order linear differential equation in u=1/yn−1.
  1. Solve :

     xy′+2y+xy2=0

     Input :
     `desolve(x*y’+2*y+x*y```^```2,y)`
     Output :
     `[1/(exp(2*ln(x))*(-1/x+c_0))]`
  2. Solve :

     xy′−2y=xy3

     Input :
     `desolve(x*y’-2*y-x*y```^```3,y)`
     Output :
     `[((-2*1/5*x```^```5+c_0)*exp(-(4*log(x))))```^```(1/-2),`
     `-((-2*1/5*x```^```5+c_0)*exp(-(4*log(x))))```^```(1/-2)]`
  3. Solve :

     x2y′−2y=xe(4/x)y3

     Input :
     `desolve(x*y’-2*y-x*exp(4/x)*y```^```3,y)`
     Output :
     `[((-2*ln(x)+c_0)*exp(-(4*(-(1/x)))))```^```(1/-2),`
     `-(((-2*ln(x)+c_0)*exp(-(4*(-(1/x)))))```^```(1/-2))]`
- Examples of first order homogeneous differential equations (y′=F(y/x), the method of integration is to search t=y/x instead of y).
  1. Solve :

     (3x3y′=y(3x2−y2)

     Input :
     `desolve(3*x```^```3*diff(y)=((3*x```^```2-y```^```2)*y),y)`
     Output :
     `[0,pnt[c_0*exp((3*1/2)/(‘ t‘```^```2)),‘ t‘*c_0*exp((3*1/2)/(‘ t‘```^```2))]]`
     hence the solutions are y=0 and the familiy of curves of parametric equation x=c0exp(3/(2t2)), y=t*c0exp(3/(2t2)) (the parameter is denoted by `‘ t‘` in the answer).
  2. Solve :

     xy′=y+ | √ |
     x2+y2

     Input :
     `desolve(x*y’=y+sqrt(x```^```2+y```^```2),y)`
     Output :
     `[(-i)*x,(i)*x,pnt[c_0/(sqrt(‘ t‘```^```2+1)-‘ t‘),(‘ t‘*c_0)/(sqrt(‘ t‘```^```2+1)-‘ t‘)]]`
     hence the solutions are :

     y=ix,y=−ix

     and the family of curves of parametric equations

     x=c0/( | √ |
     t2+1
     | −t), y=t*c0/( | √ |
     t2+1
     | −t)

     (the parameter is denoted by `‘ t‘` in the answer).
- Examples of first order differential equations with an integrating factor. By multiplying the equation by a function of x,y, it becomes a closed differential form.
  1. Solve :

     yy′+x

     Input :
     `desolve(y*y’+x,y)`
     Output :
     `[sqrt(-2*c_0-x```^```2),-(sqrt(-2*c_0-x```^```2))]`
     In this example, xdx+ydy is closed, the integrating factor was 1.
  2. Solve :

     2xyy′+x2−y2+a2=0

     Input :
     `desolve(2*x*y*y’+x```^```2-y```^```2+a```^```2,y)`
     Output :
     `[sqrt(a```^```2-x```^```2-c_1*x),-(sqrt(a```^```2-x```^```2-c_1*x))]`
     In this example, the integrating factor was 1/x2.
- Example of first order differential equations without x.
  Solve :

  (y+y′)4+y′+3y=0

  This kind of equations can not be solved directly by `Xcas`, we explain how to solve them with it’s help. The idea is to find a parametric representation of F(u,v)=0 where the equation is F(y,y′)=0, Let u=f(t),v=g(t) be such a parametrization of F=0, then y=f(t) and dy/dx=y′=g(t). Hence

  dy/dt=f′(t)=y′*dx/dt=g(t)*dx/dt

  The solution is the curve of parametric equations x(t), y(t)=f(t), where x(t) is solution of the differential equation g(t)dx=f′(t)dt.
  Back to the example, we put y+y′=t, hence:

  y=−t−8*t4, y′=dy/dx=3*t+8*t4 dy/dt=−1−32*t3

  therefore

  (3*t+8*t4)*dx=(−1−32*t3)dt

  Input :
  `desolve((3*t+8*t```^```4)*diff(x(t),t)=(-1-32*t```^```3),x(t))`
  Output :
  `-11*1/9*ln(8*t```^```3+3)+1/-9*ln(t```^```3)+c_0`
  eventually the solution is the curve of parametric equation :

  x(t)=−11*1/9*ln(8*t3+3)+1/−9*ln(t3)+c0, y(t)=−t−8*t4

- Examples of first order Clairaut differential equations (y=x*y′+f(y′)).
  The solutions are the lines Dm of equation y=mx+f(m) where m is a real constant.
  1. Solve :

     xy′+y′3−y)=0

     Input :
     `desolve(x*y’+y’```^```3-y),y)`
     Output :
     `c_0*x+c_0```^```3`
  2. Solve :

     y−xy′= | √ |
     a2+b2*y′2
     | =0

     Input :
     `desolve((y-x*y’-sqrt(a```^```2+b```^```2*y’```^```2),y)`
     Output :
     `c_0*x+sqrt(a```^```2+b```^```2*c_0```^```2)`