$\int e^{-x^2} \, \mathbb{d} x$, the Gaussian integral, is notorious throughout physics and statistics. Its definite integral defined over $\mathbb{R}$ is $\sqrt{\pi}$. However, the current indefinite integral is not an elementary solution.
Recently I thought about an integration technique that uses "error correcting." If we define a function $f(x)$ such that $f^{(n)}(x)$ still contains terms from $f(x)$ (most likely $f(x)$ will always contain $e^x$), then we can take its derivative, set it up to attempt at the integral, and correct any errors until solution is satisfied. Here's how I went about it: $$\int e^{-x^2} \, \mathbb{d} x \\ \frac{\mathbb{d}}{\mathbb{d}x} [e^{-x^2}] = -2xe^{-x^2}$$ We can therefore take a naïve guess and state that: $$\int e^{-x^2} \, \mathbb{d} x = -\frac 1 {2x} e^{-x^2}$$ This isn't true, because differentiated, the result is: $$e^{-x^2} (1 + \frac 1 {2x^2})$$ Using this, we could try to subtract $\frac{e^{-x^2}}{2x^2}$ from our first approximation of the integral (again, naïve): $$\int e^{-x^2} \, \mathbb{d} x = e^{-x^2} (-\frac 1 {2x} - \frac 1 {2x^2})$$ Differentiating: $$e^{-x^2}(1 + x^{-1} + \frac 1 2 x^{-2} + x^{-3})$$ The last three terms seem pretty simple to take the integral of, so if we subtract the integral of those three terms from our guess, perhaps we could obtain the correct answer. Let $\phi$ be our approximation. $$\phi = e^{-x^2} (-\frac 1 {2x} - \frac 1 {2x^2}) - (\int \frac {e^{-x^2}} x \, \mathbb{d} x + \int \frac{e^{-x^2}} {x^2} \, \mathbb{d} x + \int \frac{e^{-x^2}} {x^3} \, \mathbb{d} x)$$ $$\int \frac {e^{-x^2}} x \, \mathbb{d} x$$ Let us substitute $u = x^2$ and $\mathbb{d}u = 2x \mathbb{d}x$. $$\frac 1 2 \int \frac {e^{-u}} u \, \mathbb{d} u$$ Substitute $A = e^{-u}$ and $\mathbb{d}A = -e^{-u}$. $$\frac 1 2 \int \frac {\mathbb{d}A} {\ln A}$$ This is a relatively simple integral. $$\frac 1 2 \int \frac {\mathbb{d}A} {\ln A} = \frac 1 2 (\ln |\ln A| + \ln A + \sum_{k=2}^{\infty} \frac{\ln^k A}{k k!})$$ We can do the exact same substitution for $\int \frac{e^{-x^2}} {x^3} \, \mathbb{d} x$. $$\int \frac{e^{-x^2}} {x^3} \, \mathbb{d} x = \frac 1 2 \int \frac {\mathbb{d}A} {\ln^2 A} \\ = \frac 1 2 (\ln |\ln A| + \ln A + \sum_{k=2}^{\infty} \frac{\ln^k A}{k k!} - \frac A {\ln A})$$ However, $\int \frac{e^{-x^2}} {x^2} \, \mathbb{d} x$ requires a different substitution. Substitute $u = x^4$, $\mathbb{d}u = 4x^3 \mathbb{d}x$, $G = e^{-u^{1/2}}$, and $\mathbb{d}G = -\frac 1 2 u^{-1/2} e^{-u^{1/2}} \mathbb{d}u$. $$\int \frac{e^{-x^2}} {x^2} \, \mathbb{d} x = \frac 1 2 \int \frac{\mathbb{d}G}{\ln^2 G} \\ = \frac 1 2 (\ln |\ln G| + \ln G + \sum_{k=2}^{\infty} \frac{\ln^k G}{k k!} - \frac G {\ln G})$$ If we substitute, we find that the integral of $e^{-x^2}$ should be: $$-e^{-x^2}(\frac 1 {2x} + \frac 1 {2x^2}) + \frac 3 2 (\ln|x^2| - x^2 + \sum_{k=2}^{\infty}\frac{(-x^2)^k}{k k!}) + \frac {e^{-x^2}}{x^2}$$ However, I believe this evaluates to (when differentiated): $$e^{-x^2} + \frac 2 x (e^{-x^2} + \frac{e^{-x^2}} x) - \frac {e^{-x^2}} {x^3}$$ I may have made an error in that calculation. Either I am close or I have errored in the final product. Either way, is this a valid method? If so, could someone point out my error? If not, what is the issue?