How to numerically find initial values of a differential equation that gives us a solution that goes to 0 at infinity.

42 Views Asked by At

I am new to numerically solving differential equations and the problem I'm working with involves finding the initial values for a second order differential equation that would give us a solution that goes to 0 as x goes to infinity. I will provide an example, for which I already know an answer to. $$y'' - y = 0$$ With initial conditions of $y(0) = -1$ and $y'(0) = -1$ we get a solution that goes to 0 as $\lim_{x\rightarrow \infty} y(x) =0$.

I will provide the code that I use to plot the result in jupyter notebook:

from scipy.integrate import odeint
import matplotlib.pyplot as plt
import numpy as np
def model(y,x):
       u,v=y
       dydx=[v,u]
       return dydx
x=np.linspace(0,5,100)
sol=odeint(model,[1,-1],x)
plt.plot(x,sol[:,0]) 

Here we get the following plot: y'(0) = -1

Now if we were to change the initial value at $y'(0) = 0.99$ we would get the function that would go to infinity. Here is the plot with the said change: y'(0) = -0.99 My goal is to find a way to find the value of $y'(0)$ that gives us a solution to a differential equation, which goes to $0$ at infinity. If there exists a method for this already, I would appreciate knowing it's name so that I can learn it. I also want to know if the method I use for numerically solving the differential equation matters for such a problem. (I used a method from scipy called odeint, I'm curious if I should be using something else).

I am also new to stack exchange so if the way I formatted the question is not ideal, please go easy on me.