Relative Content

Tag Archive for pythonscipynumerical-methodsnumerical-integration

SciPy’s solve_bvp going solving for the wrong parameter values

I am solving a ordinary differential equation with scipy‘s solve_bvp to get a family of eigenstates phi_n and eigenvalues omega_n. The equation looks something like
y'' = -(omega_n - f(x)) ** 2 * y,
and I want it to obey the boundary conditions
y(0)=y(1)=0.
f(x) is a given function that depends on some physical parameters.

how to prevent scipy’s solve_ivp solution error from increasing in large domain

My code is used to simulate various forms of the differential equation -2 / (h(t) - λ(t)) for some starting point h0 and driver λ(t). I’ve ran this for some h0 and λ(t) with good success (such as λ(t) = 0 and λ(t) = sqrt(t)), however I noticed that in some situations (such as this current one) the solution can veer off quite a bit. In this case here, with λ(t) = t, the differential equation to solve is dhdt = -2 / (h(t) - t) with h0 = -2 .

what happens if solve_ivp’s solution contains a complex values?

I’m attempting to use scipy’s solve_ivp in order to perform some numerical analysis on Loewner equations, specifically on the first hitting time between the solution and a certain function. My question is, what happens if part of solve_ivp’s solution becomes complex? For example, if I am calculating the solution for -2 / (h(t)-sqrt(t)) with some h(0), and I know for certainty through complex analysis that the solution contains complex values after time t, how will that output look on the solution? So far the output of my solution after time t when the solution becomes complex still spits out real values. Are these the real parts of the complex values? Similarly, can you tell if the solution provided by solve_ivp contains complex values if you weren’t sure if it did? I’m using the RK45 method which supports complex values. I also find that when I am using solve_ivp and that solution contains real and complex curves, solve_ivp will stall if it tries solving for complex curves that don’t have real parts.