How do I get Sympy dsolve to produce all the eigenvectors for a ODE?

31 Views Asked by At

I am using dsolve on a basic ODE and I am getting f(x) = 0 as the only result. This is a valid result but there are infinitely many Eigenvector solutions to this equation. How do I encourage SYMPY to produce a list of them all?

I have attached the output from Mathematica, which has the full solution.

ODE = sy.Derivative(f,x,2) + λ**2 * f 
ODE

initial_conditions = {f.subs(x,0):0, f.subs(x,1):0}
sol=sy.dsolve(ODE,f, ics=initial_conditions)
sol

f(x) = 0

1

There are 1 best solutions below

2
Oscar Benjamin On

You can get the general solution from dsolve if you do not specify any initial conditions:

In [25]: x = symbols('x', real=True)

In [26]: l = symbols('lambda', positive=True)

In [27]: f = Function('f')

In [28]: initial_conditions = {f(0):0, f(1): 0}

In [29]: eq = f(x).diff(x, 2) + l**2 * f(x)

In [30]: dsolve(eq)
Out[30]: f(x) = C₁⋅sin(λ⋅x) + C₂⋅cos(λ⋅x)

In [31]: dsolve(eq, ics=initial_conditions)
Out[31]: f(x) = 0

The ODE has infinitely many solutions but only one of those satisfies the initial conditions that you have provided.