 Jaydan Aguirre

2022-07-04

The problem is of the following form: $\frac{dr}{dt}$=$f\left(r\right)$, so $\frac{1}{f\left(r\right)}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\left(0\right)={r}_{0}$ and $r\left(\mathrm{\infty }\right)=\mathrm{\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. Sariah Glover

Expert

First of all, this is a first order problem, you do not get to fix two conditions, only one. Once you choose $r\left(0\right)={r}_{0}$, the solution is determined for all t and it may or may not satisfy $r\left(\mathrm{\infty }\right)=\mathrm{\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
$\left\{\begin{array}{l}{R}_{0}=r\left({t}_{0}\right)={r}_{0}\\ {R}_{n+1}={R}_{n}+hf\left({R}_{n}\right)\end{array}$
Naturally, ${R}_{i}$ will be the approximate value of $r\left({t}_{i}\right)$. 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\left(t+h\right)=r\left(t\right)+{\int }_{t}^{t+h}f\left(r\left(s\right)\right)\phantom{\rule{thinmathspace}{0ex}}ds\approx r\left(t\right)+hf\left(r\left(t\right)\right).$

Do you have a similar question?