TITLE: Differential equation with non-elementary function
QUESTION [1 upvotes]: Can a solution be found to the following differential equation:
$$ \dfrac {dy}{dx}=e^{-x^2}$$ given the initial conditions $y(0) = c$ - some constant?
I know that $y(x)$ is a non-elementary function but could a solution be obtained numerically?

REPLY [0 votes]: The solution is
$$y=c+\frac{\sqrt{\pi }}{2}  \text{erf}(x)$$ If you cannot use the error function, you could use, as an approximation,
$$\text{erf}(x)\sim \sqrt{1-\exp\Big(-\frac 4 {\pi}\,\frac{1+\alpha x^2}{1+\beta x^2}\,x^2 \Big)}$$ where $$\alpha=\frac{10-\pi ^2}{5 (\pi -3) \pi }\qquad \text{and} \qquad\beta=\frac{120-60 \pi +7 \pi ^2}{15 (\pi -3) \pi }$$ or much better (just made for you)
$$\text{erf}(x)\sim \sqrt{1-\exp\Big(-\frac 4 {\pi}\,\frac{1+\frac{509 }{4044}x^2+\frac{391 }{29717}x^4}{1+\frac{505 }{3239}x^2+\frac{35 }{2306}x^4}\,x^2 \Big)}$$ I have the exact expression of the coefficients but they are really messy. This last formula gives a maximum absolute error of $10^{-5}$ around $x=2$.
{"set_name": "stack_exchange", "score": 1, "question_id": 3746489}