The title itself is self explanatory - I am trying to numerically solve an ODE with an initial value that has an infinite gradient. It seemed problematic to me and I am not certain as to how I should approach this.

e.g. $\frac {dy}{dx} = \frac y{\sqrt x} , y(0)=1$

(Obviously this can be solved analytically but I would like to know if there is any numerical method that tackles problems like this)

Thank you very much!


Others can probably give a more "conventional" approach but one thing you can do, because $y'(x)$ is independent of $y(x)$, is take the following approach for the first step (at least).

For the initial slope think rather angle. You want to proceed with a certain angle but you can't use $\theta_1=\frac{\pi}{2}$... which is obviously no good.

Instead take as angle the mid-angle of $\theta_1=\pi/2$ and the angle of the curve at $x=h$:


and so take as initial angle:


and so an initial slope of:


From here you can do normal Euler or perhaps keep it going with slope


This is an adaptation of Heun's Method. With a step-size of $h=0.1$ this gives an error for $y_1\approx y(x_1)$ of the order of $0.015$.

  • $\begingroup$ I should have make it clear that the ODE should be inhomogenous. Thank you for your answer though. $\endgroup$ – cssstudent Dec 12 '17 at 15:44
  • $\begingroup$ @cssstudent perhaps perturb the initial condition to $y(\varepsilon)=1$? $\endgroup$ – JP McCarthy Dec 14 '17 at 14:38
  • 1
    $\begingroup$ yes - that is perhaps the most simple way $\endgroup$ – cssstudent Dec 14 '17 at 18:54

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.