Repository: sympy/sympy
File: sympy/solvers/ode/single.py (Python)

Code before:
            else:
                coeff2[d4] = factor(_coeff2[b]).match(d4**2)[d4]

            self.rn = {'n':coeff2[d4], 'a4':coeff2[c4], 'd4':coeff2[a4]}
            self.rn['c4'] = coeff1[a4]
            self.rn['b4'] = point
            return True
        return False

    def _get_general_solution(self, *, simplify_flag: bool = True):
        f = self.ode_problem.func.func
        x = self.ode_problem.sym
        n = self.rn['n']
        a4 = self.rn['a4']
        c4 = self.rn['c4']
        d4 = self.rn['d4']
        b4 = self.rn['b4']
        n = sqrt(n**2 + Rational(1, 4)*(c4 - 1)**2)
        (C1, C2) = self.ode_problem.get_numbered_constants(num=2)
        return [Eq(f(x), ((x**(Rational(1-c4,2)))*(C1*besselj(n/d4,a4*x**d4/d4)
            + C2*bessely(n/d4,a4*x**d4/d4))).subs(x, x-b4))]


class SecondLinearBesselTransform(SingleODESolver):
    r"""
    Solves second-order ODEs of the form y'' + A*x^k*y = 0 where k is symbolic.

    These equations have solutions in terms of Bessel functions.

    The general solution is:

    .. math:: y(x) = \sqrt{x} \left[C_1 J_\nu(z) + C_2 Y_\nu(z)\right]

    where :math:`\nu = \frac{1}{k+2}` and :math:`z = \frac{2}{k+2} x^{(k+2)/2}`

    Examples
    ========

    >>> from sympy import symbols, Function, dsolve, Derivative
    >>> x, k = symbols('x k')
    >>> y = Function('y')
    >>> dsolve(Derivative(y(x), (x, 2)) + x**k*y(x))
    Eq(y(x), sqrt(x)*(C1*besselj(1/(k + 2), 2*x**(k/2 + 1)/(k + 2)) +
                  C2*bessely(1/(k + 2), 2*x**(k/2 + 1)/(k + 2))))

    References
    ==========
    - Abramowitz & Stegun, Handbook of Mathematical Functions, 9.1.52
    - https://eqworld.ipmnet.ru/en/solutions/ode/ode0201.pdf
    """
    hint = "2nd_linear_bessel_transform"

Review comment (suggestion):
The "where k is symbolic" part here does not mean anything because `k` can be anything except 2.

Code after:
            else:
                coeff2[d4] = factor(_coeff2[b]).match(d4**2)[d4]

            self.rn = {'n':coeff2[d4], 'a4':coeff2[c4], 'd4':coeff2[a4]}
            self.rn['c4'] = coeff1[a4]
            self.rn['b4'] = point
            return True
        return False

    def _get_general_solution(self, *, simplify_flag: bool = True):
        f = self.ode_problem.func.func
        x = self.ode_problem.sym
        n = self.rn['n']
        a4 = self.rn['a4']
        c4 = self.rn['c4']
        d4 = self.rn['d4']
        b4 = self.rn['b4']
        n = sqrt(n**2 + Rational(1, 4)*(c4 - 1)**2)
        (C1, C2) = self.ode_problem.get_numbered_constants(num=2)
        return [Eq(f(x), ((x**(Rational(1-c4,2)))*(C1*besselj(n/d4,a4*x**d4/d4)
            + C2*bessely(n/d4,a4*x**d4/d4))).subs(x, x-b4))]


class SecondLinearBesselTransform(SingleODESolver):
    r"""
    Solves second-order ODEs of the form y'' + A*x^k*y = 0.

    These equations have solutions in terms of Bessel functions.

    The general solution is:

    .. math:: y(x) = \sqrt{x} \left[C_1 J_\nu(z) + C_2 Y_\nu(z)\right]

    where :math:`\nu = \frac{1}{k+2}` and :math:`z = \frac{2}{k+2} x^{(k+2)/2}`

    Examples
    ========

    >>> from sympy import symbols, Function, dsolve, Derivative
    >>> x, k = symbols('x k')
    >>> y = Function('y')
    >>> dsolve(Derivative(y(x), (x, 2)) + x**k*y(x))
    Eq(y(x), sqrt(x)*(C1*besselj(1/(k + 2), 2*x**(k/2 + 1)/(k + 2)) +
                  C2*bessely(1/(k + 2), 2*x**(k/2 + 1)/(k + 2))))

    References
    ==========
    - Abramowitz & Stegun, Handbook of Mathematical Functions, 9.1.52
    - https://eqworld.ipmnet.ru/en/solutions/ode/ode0201.pdf
    """
    hint = "2nd_linear_bessel_transform"