3.2 How to force dsolve to use specific method for solving?

To find what methods dsolve uses do

`dsolve/methods`[1] 
 
     [quadrature, linear, Bernoulli, separable, inverse_linear, 
      homogeneous, Chini, lin_sym, exact, Abel, pot_sym]
 

The above gives methods for first order ODEs. More are given by

`dsolve/methods`[1,'semiclass'] 
 
     [Riccati, inverse_Riccati, equivalent_to_Abel, 
      linearizable, linearizable_by_differentiation] 
 
`dsolve/methods`[1,'high_degree'] 
 
     [WeierstrassP, WeierstrassPPrime, JacobiSN, linearizable_by_differentiation, 
      missing, dAlembert, homogeneous_B, sym_implicit] 
 
`dsolve/methods`[1,"development"] 
 
     [linearizable_by_differentiation, linearizable, con_sym, 
      WeierstrassP, WeierstrassPPrime, equivalent_to_Abel, 
      Abel_AIR, special, Riccati_symmetries] 
 
`dsolve/methods`[1,extra] 
     [inverse_Riccati, Abel_AIL, `sym_pat/[F(x)*G(y),0]`, `sym_pat/[F(x),G(x)]`, 
      `sym_pat/[F(x),G(y)]`, `sym_pat/[F(x)+G(y),0]`, 
      `sym_pat/[F(x),G(x)*y+H(x)]`, sym_pat, exp_sym]
 

For example given a first order ode, we can ask dsolve to solve it using one of these methods as follows

restart; 
ode:=diff(y(x),x)=sqrt( sqrt( y(x) )* sin(x))/sqrt(y(x)) 
dsolve(ode,y(x),[`exact`]) 
 
     4/5*y(x)^(5/4) + Intat(-sqrt(sqrt(y(x))*sin(_a))/y(x)^(1/4), _a = x) + c__1 = 0
 

We can ask it to use symmetry with specific pattern as follows

restart; 
ode:=diff(y(x),x)=sqrt( sqrt( y(x) )* sin(x))/sqrt(y(x)) 
dsolve(ode,y(x),[`sym_pat/[F(x),G(x)*y+H(x)]`]) 
 
    c__1 + 4/5*y(x)^(3/2)*sqrt(sin(x))/sqrt(sqrt(y(x))*sin(x)) - Int(sqrt(sin(x)), x) = 0 
 
#or using short cut, same thing can be done as follows 
dsolve(ode,y(x),Lie) 
 
    c__1 + 4/5*y(x)^(3/2)*sqrt(sin(x))/sqrt(sqrt(y(x))*sin(x)) - Int(sqrt(sin(x)), x) = 0 
 
#another short cut for Lie is 
dsolve(ode,[`sym_pat`]) 
 
    c__1 + 4/5*y(x)^(3/2)*sqrt(sin(x))/sqrt(sqrt(y(x))*sin(x)) - Int(sqrt(sin(x)), x) = 0
 

To find all methods, and for higher order ode, we first use indices as follows

indices(`dsolve/methods`) 
 
    [high, linear_nonhomogeneous], 
    [1], 
    [1, high_degree], 
    [3, linear_homogeneous], 
    [2, "linear_homogeneous all methods"], 
    [2, "linear_homogeneous other"], 
    [2, linear_homogeneous], 
    [2, "special_functions"], 
    [3, linear_nonhomogeneous], 
    [2, "linear_homogeneous in Normal Form"], 
    [2, "development"], [2, "hypergeometric"], 
    [1, extra], 
    [high, linear_homogeneous], 
    [high, nonlinear], 
    [1, "special"], 
    [1, "development"], 
    [2, nonlinear], 
    [high, "development"], 
    [1, semiclass], 
    [3, nonlinear], 
    [2, linear_nonhomogeneous], 
    [2, "linear_homogeneous as given"], 
    [3, "development"]
 

Using the above, to find all methods for second order linear_homogeneous ode, the command is

`dsolve/methods`[2, "linear_homogeneous all methods"] 
 
    [quadrature, const_coeffs, Euler, linear_1, 
     `linear/missing_y`, Kovacic, special_functions, to_const_coeffs, 
      exact_linear, sym_1, Mathieu, MeijerG, Heun, HeunG, HeunC, HeunB, HeunD, 
      HeunT, mu_xy, equivalent_to_Bessel, to_Riccati, Bessel, elliptic, 
      Legendre, Whittaker, Kummer, cylindrical, hypergeometric, hypergeom1, 
      hypergeom2, Riemann, RNF, hypergeometricsols, rationalize_lode, with_periodic_functions] 
 
`dsolve/methods`[2, "linear_homogeneous other"] 
 
    [exact_linear, sym_1, to_const_coeffs, mu_xy, equivalent_to_Bessel, 
     to_Riccati, with_periodic_functions]
 

For example, given the ode \(y''+3 y'+ y=0\), we can now do

dsolve(ode,y(x)) 
     y(x) = c__1*exp(1/2*(sqrt(5) - 3)*x) + c__2*exp(-1/2*(3 + sqrt(5))*x) 
 
dsolve(ode,y(x),[`const_coeffs`]) 
    y(x) = c__1*exp(1/2*(sqrt(5) - 3)*x) + c__2*exp(-1/2*(3 + sqrt(5))*x) 
 
dsolve(ode,y(x),[`Kovacic`]) 
    y(x) = c__1*exp(1/2*(sqrt(5) - 3)*x) + c__2*exp(-1/2*(3 + sqrt(5))*x)
 

Not all methods ofcourse will work, as it depends on the ode type.

This function below lists all methods

ind:=indices(`dsolve/methods`); 
for item in ind do 
    cat("`dsolve/methods`",String(item)); 
    eval(parse(%)) 
od;
 

Which gives

"`dsolve/methods`[high, linear_nonhomogeneous]" 
    [quadrature, fully_exact_linear, linear_nonhomogeneous_[0,1], 
    exact_linear_nonhomogeneous, linear, exp_reduce] 
 
 
"`dsolve/methods`[1]" 
  [quadrature, linear, Bernoulli, separable, inverse_linear, 
    homogeneous, Chini, lin_sym, exact, Abel, pot_sym] 
 
"`dsolve/methods`[1, high_degree]" 
    [WeierstrassP, WeierstrassPPrime, JacobiSN, 
      linearizable_by_differentiation, missing, dAlembert, 
      homogeneous_B, sym_implicit] 
 
 
"`dsolve/methods`[3, linear_homogeneous]" 
     [quadrature, const_coeffs, Euler, fully_exact_linear, 
       to_const_coeffs, linear, exp_reduce, exact_linear, 
       with_periodic_functions] 
 
 
"`dsolve/methods`[2, "linear_homogeneous all methods"]" 
     [quadrature, const_coeffs, Euler, linear_1, linear/missing_y, 
      Kovacic, special_functions, to_const_coeffs, exact_linear, 
      sym_1, Mathieu, MeijerG, Heun, HeunG, HeunC, HeunB, HeunD, 
      HeunT, mu_xy, equivalent_to_Bessel, to_Riccati, Bessel, 
      elliptic, Legendre, Whittaker, Kummer, cylindrical, 
      hypergeometric, hypergeom1, hypergeom2, Riemann, RNF, 
      hypergeometricsols, rationalize_lode, with_periodic_functions] 
 
 
"`dsolve/methods`[2, "linear_homogeneous other"]" 
      [exact_linear, sym_1, to_const_coeffs, mu_xy, 
       equivalent_to_Bessel, to_Riccati, with_periodic_functions] 
 
"`dsolve/methods`[2, linear_homogeneous]" 
                      [linear_homogeneous] 
 
"`dsolve/methods`[2, "special_functions"]" 
    [Bessel, elliptic, Legendre, Kummer, Whittaker, hypergeometric, Mathieu] 
 
 
"`dsolve/methods`[3, linear_nonhomogeneous]" 
     [quadrature, fully_exact_linear, linear_nonhomogeneous_[0,1], 
      exact_linear_nonhomogeneous, linear, exp_reduce] 
 
 
"`dsolve/methods`[2, "linear_homogeneous in Normal Form"]" 
                           [linear_1] 
 
"`dsolve/methods`[2, "development"]" 
    [mu_xyp, mu_xyp2, mu_formal, mu_heuristic, exp_reduce, linear, 
     Bessel2, Whittaker_old, nonlinear_homogeneous, 
     exact_linear_nonhomogeneous, mu_y1, mu_x_y1, mu_y_y1, 
     mu_poly_yn, exp_sym, sym_pat, sym_8] 
 
 
"`dsolve/methods`[2, "hypergeometric"]" 
                      [hypergeom1, hyper3] 
 
"`dsolve/methods`[1, extra]" 
      [inverse_Riccati, Abel_AIL, sym_pat/[F(x)*G(y),0], 
       sym_pat/[F(x),G(x)], sym_pat/[F(x),G(y)], 
       sym_pat/[F(x)+G(y),0], sym_pat/[F(x),G(x)*y+H(x)], sym_pat, 
       exp_sym] 
 
 
"`dsolve/methods`[high, linear_homogeneous]" 
     [quadrature, const_coeffs, Euler, fully_exact_linear, 
       to_const_coeffs, linear, exp_reduce, exact_linear, 
       with_periodic_functions] 
 
"`dsolve/methods`[high, nonlinear]" 
     [linearizable_by_differentiation, linearizable, reducible, 
      exact_nonlinear, missing, mu_formal, lin_sym] 
 
"`dsolve/methods`[1, "special"]" 
                            [80, 81] 
 
"`dsolve/methods`[1, "development"]" 
     [linearizable_by_differentiation, linearizable, con_sym, 
      WeierstrassP, WeierstrassPPrime, equivalent_to_Abel, Abel_AIR, 
      special, Riccati_symmetries] 
 
 
"`dsolve/methods`[2, nonlinear]" 
    [Liouville, WeierstrassP, JacobiSN, linearizable, 
    linearizable_by_differentiation, mu_xy_2, missing, 
    mu_xyp2_dynamical_symmetries_fully_reducible, 
    mu_xyp_singularcases, sym_1, exact_nonlinear, reducible, 
    lin_sym, S-function, mu_xyp_generalcase, 
    mu_xyp2_dynamical_symmetries_not_fully_reducible] 
 
 
"`dsolve/methods`[high, "development"]" 
    [k25, RNF, mu_heuristic, MeijerG, nonlinear_homogeneous, 
     mu_poly_yn, exp_sym] 
 
"`dsolve/methods`[1, semiclass]" 
    [Riccati, inverse_Riccati, equivalent_to_Abel, linearizable, 
     linearizable_by_differentiation] 
 
 
"`dsolve/methods`[3, nonlinear]" 
   [linearizable_by_differentiation, linearizable, missing, 
     exact_nonlinear, reducible, mu_formal, lin_sym] 
 
 
"`dsolve/methods`[2, linear_nonhomogeneous]" 
     [quadrature, fully_exact_linear, linear_nonhomogeneous_[0,1], 
      linear_nonhomogeneous_[0,F(x)], linear_nonhomogeneous] 
 
"`dsolve/methods`[2, "linear_homogeneous as given"]" 
     [quadrature, const_coeffs, Euler, linear_1, linear/missing_y, 
      Kovacic, RNF, special_functions, MeijerG, Heun, 
      hypergeometricsols, rationalize_lode] 
 
"`dsolve/methods`[3, "development"]" 
     [k25, RNF, mu_heuristic, linear_patterns, MeijerG, 
      nonlinear_homogeneous, mu_y2, mu_poly_yn, exp_sym, pFq, 3F2, 
      2F2, 1F2, 0F2]