Crash with DSolve. No possible closed form?

I want to solve the following differential equation:

eq=N*D[q[x],{x,2}]-(6x-x^2)*D[q[x],{x,1}]-s*q[x]==-1
DSolve[eq, q[x],x]

But I get no solution. If I change the (6x-x^2) coefficient by 6x or 6/x I get a solution, so I was wondering if Mathematica cannot solve this or if there is no closed form solution at all.

• Maple 2021 can solve.Solution by HeunT function. May 6 '21 at 13:46
• There is a solution in V12.2. Note N is a protected symbol, which should not be used as a variable/parameter. (See #4 mathematica.stackexchange.com/a/18395) May 6 '21 at 13:51
• In fact, Methematica 12.2 returns the input. Maple 2021 answers $$q\! \left(x\right)=\mathrm{HeunT}\! \left(-\frac{3^{\frac{2}{3}} s}{n^{\frac{1}{3}}},3,-\frac{9 \,3^{\frac{1}{3}}}{n^{\frac{2}{3}}},-\frac{3^{\frac{2}{3}} \left(x-3\right)}{3 n^{\frac{1}{3}}}\right) \textit{_}\mathit{C2}+{\mathrm e}^{-\frac{x^{2} \left(x-9\right)}{3 n}} \mathrm{HeunT}\! \left(-\frac{3^{\frac{2}{3}} s}{n^{\frac{1}{3}}},-3,-\frac{9 \,3^{\frac{1}{3}}}{n^{\frac{2}{3}}},\frac{3^{\frac{2}{3}} \left(x-3\right)}{3 n^{\frac{1}{3}}}\right) \textit{_}\mathit{C1}+\frac{1}{s}$$, but May 6 '21 at 13:57
• the HeunT function is a special function for the notation of the solutions of certain ODEs. May 6 '21 at 14:00
• In fact, V12.2.0.0/MacOS returns a (somewhat obvious) differential root (from a fresh kernel). Seems to me that should happen in earlier versions, at least recent ones. I get the same in V12.0.0.0, too. I cannot test earlier versions. May 6 '21 at 14:11

\$Version

(* "12.2.0 for Mac OS X x86 (64-bit) (December 12, 2020)" *)

Clear["Global`*"]

eqn = {
n*q''[x] - (6 x - x^2)*q'[x] - s*q[x] == -1,
q == q0, q' == qp0};

The solution is given as a DifferentialRoot

(sol[q0_, qp0_, n_, s_] = DSolve[eqn, q, x][]) % // InputForm To numerically evaluate the solution, the initial conditions and all variables must be given values:

(q[1.0] /. sol[0, 1, 2, 1/2])

(* 1.37193 *)

Or using ParametricNDSolve for a numeric solution

soln = ParametricNDSolve[eqn, q, {x, 0, 2},
{q0, qp0, n, s}]

q[0, 1, 2, 1/2][1.0] /. soln

(* 1.37193 *)

Manipulate[
Plot3D[
Evaluate[q[q0, qp0, 2, s][x] /. soln],
{x, 0, 2}, {n, -3, 3},
AxesLabel -> (Style[#, 12, Bold] & /@ {x, n, q})],
{{q0, 0, "q"}, -1, 1, 0.05,
Appearance -> "Labeled"},
{{qp0, 0.35, "q'"}, -1, 1, 0.05,
Appearance -> "Labeled"},
{{s, 0.5}, -5, 5, 0.5,
Appearance -> "Labeled"}] 