The problem is of the following form: $\frac{dr}{dt}$ = $f(r)$, so $\frac{1}{f(r)} dr = dt$. My goal is to get some $r(t)$ from this differential equation by numerically integrating this, that is, a value for $r$ at every $t$. The conditions are $r(0) = r_0$ and $r(\infty) = \infty$. The problem I run into is that I am not quite sure what the limits would be to get such values for $r(t)$. Any suggestions on where to go from this would be greatly appreciated, thanks.
2026-04-30 08:41:57.1777538517
Solving first order differential equation numerically
176 Views Asked by Bumbble Comm https://math.techqa.club/user/bumbble-comm/detail At
3
First of all, this is a first order problem, you do not get to fix two conditions, only one. Once you choose $r(0)=r_0$, the solution is determined for all $t$ and it may or may not satisfy $r(\infty)=\infty$. The simplest method you can use is Euler's method: you choose equally spaced points $t_0,t_1=t_0+h, t_2=t_0+2h, \cdots$, and build the sequence $$ \begin{cases} R_0 = r(t_0)=r_0\\ R_{n+1}=R_n + h f(R_n) \end{cases} $$
Naturally, $R_i$ will be the approximate value of $r(t_i)$. You may have to use very small $h$ for precise results but it has the advantage of being very easy to implement. If you want more accurate methods, you may want to lookup Runge-Kutta methods.
In terms of the integral form of the equation this corresponds to say that
$$ r(t+h)= r(t) + \int_t^{t+h} f(r(s)) \,ds \approx r(t) + h f(r(t)).$$