0
$\begingroup$

Say we want to solve numerically $y'(x) = f(x) \cdot y$, with $y_0 = y(x=0) = 0$ and applying RK4 method with step $dx = h$:

\begin{align} k_1 &= f(0) \cdot y(0) \cdot h = 0\\ k_2 &= f(0+h/2) \cdot (y_0 + k_1/2) \cdot h = f(h/2) \cdot 0 = 0\\ k_3 &= f(h/2) \cdot (y_0 + k_2/2) \cdot h = 0\\ k_4 &= f(c+h) \cdot (y_0 + k_3) \cdot h = 0 \end{align}

Hence: $y(h) = 0 + (k_1+2 k_2+2 k_3+k_3)/6 = 0...$

In the end: $y_i = y(0+i\cdot h) = 0$, no matter what $f(x)$ looks like!

Any suggestions on this?

$\endgroup$
  • $\begingroup$ Why would you make $y'(x)$ depend on $y$ that way? Since $y(0)=0$ and $y'(x) = f(x)\cdot y$, you have $y'(0)=0$ (because $y=0$) no matter what $f(x)$ is. Are you sure that's the equation you're trying to solve? $\endgroup$ – David K Feb 10 '16 at 3:44
  • $\begingroup$ thanks, @DavidK! $\endgroup$ – Chip Feb 10 '16 at 5:02
  • $\begingroup$ I realized that in the form I wrote it, the unique solution is zero as @runaround pointed out. However, the long story is the following: in solving the hydrogen radial Schr$\:o$dinger equation (with r the radial coordinate) for angular momentum $L=1$ and the modified radial wave function $P(r) = rR(r), P(r)$ satisfies: $P"(r) = 2(-1/r-E+1/r^2)$, where $E$ is the eigen-energy to be found. One can re-write this as first order system of equations: \begin{align} dP/dr(r) &= Q(r) \\ dQ/dr(r)&= 2(-1/r-E+1/r^2) P(r)\\ \end{align}, $P(0)=0$ and $Q(0)=0$. Hereby, RK4 will output zero for all r > 0. $\endgroup$ – Chip Feb 10 '16 at 5:15
  • 1
    $\begingroup$ Looks like a two-parameter version of the same thing. Maybe the fault is in the initial conditions. Wolfram Alpha gives as a solution $P(r) = c_2 r+c_1-e r^2-2 r log(r)-2 log(r)$, which is not defined at $r=0$. It seems the thing to do is (a) start this at a positive $r=r_0$ and (b) make at least one of $P(r_0)$ and $Q(r_0)$ non-zero. $\endgroup$ – David K Feb 10 '16 at 6:42
1
$\begingroup$

y = 0 is the solution of the equation with $y(0) = 0$. You get exact solution for this.

$\endgroup$
  • $\begingroup$ you are right. The story is a bit longer, see the above more detailed comment. $\endgroup$ – Chip Feb 10 '16 at 5:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.