Discrepancy between closed form solution and numerical solution I have the following differential equation
$$ \frac{dx}{dt} = -\frac{1}{\alpha t}x(1-x) \,,\,x\in [1,20) \tag 1$$
The solution on this interval  by taking $x(1) = 0.9999$ is given by 
$$ x(t) = \frac{1}{1+0.0001\exp\left( \frac{\ln(t) - \ln t(1)}{ \alpha}\right)}  ~. \tag 2$$
Now if $\alpha = 0.2$, then $x(20) = \lim_{x\to 20^-} x(t)$, so that $$ x(20) =\frac{1}{1+0.0001\exp\left( \frac{\ln(20)}{ 0.2}\right)}\approx 0.0031 ~. \tag 3$$ 
On the other hand discretizing (1) using Euler approximation yields 
$$ x(t_i)= x(t_{i-1}) - \frac{1}{\alpha t_{i-1}}x(t_{i-1}) (1-x(t_{i-1}) )\Delta t_i~. \tag 4$$ Then
$$ x(20) = 0.9999 - \frac{1}{0.2 \cdot 1} 0.9999\cdot (1-0.9999)\cdot (20-1) \approx  0.9904  \tag 5$$ 
I know the Euler approximation is very conservative but this result is puzzling. I'm sure I'm missing something but I don't know what. Why is there such a "big" discrepancy between (3) and (5)?
 A: The closed form solution I obtained from this is: $$ x(t) = \frac C{t^{1/\alpha} + C}$$
Note that there are several other equivalent forms that one could use, one of which is the form in Dr. Sonnhard Graubner's answer, and I think yours may also be correct, although I haven't verified it.  Anyway, with $x(1) = 0.9999$ and $\alpha = 0.2$, we have $$ x(t) = \frac{9999}{t^5 + 9999}.$$
Here we get $x(20) \approx 0.0031$, just like you did.
With Euler's method you appear to be using a very large step size of $\Delta t_i = 19$.  I think this is what's causing the problems.  We want our step sizes to be very small when using numerical methods.
When I run Euler's method through a custom spreadsheet with $\Delta t = 0.5$, I get $x(20) \approx 0.0289$.  Better, but still not great.
When I run it with $\Delta t = 0.1$, I get $x(20) \approx 0.0056$.
With $\Delta t = 0.05$, I get $x(20) \approx 0.0042$.
Finally, with $\Delta t = 0.001$, I get $x(20) \approx 0.0031$.
So overall the problem appears to be that your $\Delta t$ is just too large.

Picture of part of spreadsheet:

To create the spreadsheet:


*

*Place labels in row $1$ (or don't)

*In cell $A2$, enter 1

*In cell $B2$, enter 0.9999

*In cell $C2$, enter 0.05 (or whatever your desired $\Delta t$ is)

*In cell $A3$, enter this exactly: =A2+C$2

*In cell $B3$, enter this exactly: =B2-1/(0.2*A2)*B2*(1-B2)*C$2

*Copy cells $A3$ and $B3$ and paste them into cells $A4$ and $B4$, and cells $A5$ and $B5$, etc., as far down as you'd like to go.


As Winther pointed out in the comments, you'll need to perform multiple steps to get to $t = 20$.
Also, try doing just one step with $\Delta t = 19$.  When I do that I get $x(20) \approx 0.9904$.  More evidence that these methods are intended to be used with very small step sizes.
Compare these two plots of $x(t)$, $0 \le t \le 300$ (technically the second one goes to $t=305$ because of the step size) obtained from Euler's method, one with $\Delta t = 0.01$ and one with $\Delta t = 19$, and note the large discrepancy for $t \le 150$.

Compare also with the plot of the analytic solution using desmos.com:

A: HINT: write $$\frac{dx}{x(1-x)}=-\frac{1}{\alpha t}dt$$ the solution should be $$x(t)=\frac{1}{e^{c_1} t^{\frac{1}{\alpha }}+1}$$
