I am trying to implement a routine to solve a differential equation in Python. Basically the kind of equation that I am interested in solving is of the form:
$$\displaystyle \frac{d}{dx^2} \left(x y(x) \right) = 2 x ((U(x)-a) y(x)+ 2 b y(x)^3)$$
where $a$ is an unknown constant and $b$ is a known constant and $U(x)$ is a function that depends on $x$ but that I only know numerically (I mean, I don't have an explicit form of $U(x)$ in terms of $x$).
I need to find the value of $a$ that fulfills my initial and boundary conditions ($y(0)=y_0$ and $y(x\rightarrow \infty)=0$, $a<1$).
For that purpose, I was considering using a shooting method (a secant method to be precise) by solving several times the above equation with RK4 (using scipy.integrate.ode
).
The problem that I have is that I don't know how to introduce the numerical value of $U(x)$ in my equations given the fact that ode only asks for values at the initial conditions.
Is there a way to solve my equation with scipy.integrate.ode
or with another solver?
ode
only asks for values at the initial conditions? Looking at the documentation here, you would need to specifyf(x)
as an argument, not just at the initial conditions but as a function that can be evaluated at anyx
. More detail would definitely be helpful in answering this. $\endgroup$