I have the following first order differential equation: $$0.05u'+2xu=0.05^2e^{5-20x^2}$$ for $x \in [0,1]$, and $u(0)=0$.
then I want to approach the differential equation with a Taylor series at point $x_i$, namely: $u'_{i} \approx \dfrac{u_{i+1}-u_{i}}{h_i}$.
$h_i$ here is the width of the grid, namely $h_i=x_{i+1}-x_{i}$. Then I define the grid width $h_i$ as follows: $h_{i+1}=h_i(1+\alpha.h_{i})$. where alpha is a constant.
when I take $\alpha$ values $1,2,3,4,...,7$ the error produced around the $0.15$ point is quite large.
What alpha value should I take so that the approximation around the $0.15$ point has a small error?
Or How do I adjust the hi grid width so that the approximation results obtained are optimal?
The optimal step size has in fact a "w" shape, with the middle leg at about $x=0.27$.
With $\tau$ ($=10^{-3}$ in plot) the desired unit-step error in an variable-step Euler implementation, the first bow starts at $h=3\tau$, sweeps down to $h=0.02\tau$ and returns to $h=8\tau$. Then the second bow sweeps down to $h=0.1\tau$ at $x=0.35$ and then grows exponentially, reaching $h=10^4\tau$ at $x=1$.
So your step size scheme will indeed have problems if the prescribed step size is not small enough where the first down-swing should be, $x=0.15$ being the location of the first minimum.