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. dy/dx=y/sqrt x, y(0)=1

blackdivcp

blackdivcp

Answered question

2022-10-31

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. d y d x = y 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)

Answer & Explanation

clietsoriergono

clietsoriergono

Beginner2022-11-01Added 5 answers

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 θ 1 = π 2 ... which is obviously no good.

Instead take as angle the mid-angle of θ 1 = π / 2 and the angle of the curve at x = h:
θ 2 := tan 1 ( y ( h ) ) = tan 1 ( 1 h ) ,
and so take as initial angle:
θ 0 = θ 1 + θ 2 2 = π 2 + tan 1 ( 1 h ) 2 ,
and so an initial slope of:
m 0 := tan ( θ 0 ) .
From here you can do normal Euler or perhaps keep it going with slope
m k = y ( x k ) + y ( x k + 1 ) 2 .
This is an adaptation of Heun's Method. With a step-size of h = 0.1 this gives an error for y 1 y ( x 1 ) of the order of 0.015.

Do you have a similar question?

Recalculate according to your conditions!

Ask your question.
Get an expert answer.

Let our experts help you. Answer in as fast as 15 minutes.

Didn't find what you were looking for?