[Python] why sympy dsolve generate solution with symbol not in the ode?

Discussão em 'Python' iniciado por Stack, Fevereiro 27, 2025.

  1. Stack

    Stack Membro Participativo

    This ode has only x and y(x) in it. Yet the solution given has new symbol called r in it.

    Where did r come from and what does it mean?

    Python version: 3.13.1 (main, Dec 4 2024, 18:05:56) [GCC 14.2.1 20240910]
    Sympy version 1.13.3


    Code

    >python
    Python 3.13.1 (main, Dec 4 2024, 18:05:56) [GCC 14.2.1 20240910] on linux
    Type "help", "copyright", "credits" or "license" for more information.
    >>> from sympy import *
    >>> x = symbols("x")
    >>> y = Function("y")
    >>> ode = Eq((x - 1)*y(x) + (3*x + 6)*Derivative(y(x), x) + (x**2 + x - 2)**2*Derivative(y(x), (x, 2)),0)

    >>> dsolve(ode,func=y(x))
    Eq(y(x), x**4*r(3)/8 + 13*x**5*r(3)/80 + C2*(-9*x**5/2560 + x**4/768 + x**2/16 + 1) + C1*x*(23*x**4/640 - 7*x**3/192 - 3*x/4 + 1) + O(x**6))
    >>>


    Notice the solution above has r(3).

    It is also strange that it gives O(x) at the end. I did not ask for series solution as you see. But will leave this bit for different question.

    I am now just asking what is r above?

    Continue reading...

Compartilhe esta Página