Attempting to derive the cdf of the normal distribution from its pdf.
http://en.wikipedia.org/wiki/Normal_distribution
sage: var('x mu sigma')
sage: PDF = function('PDF', x, mu, sigma)
sage: normal = (PDF == 1/(sigma * sqrt(2 * pi))*e^(-(x - mu)^2/(2*sigma^2)))
sage: normal
PDF(x,μ,σ)=√2e(−(μ−x)22σ2)2√πσ
sage: eq1 = integrate(normal, x)
sage: eq1
∫PDF(x,μ,σ)dx=c2+12erf(−√2μ2σ+√2x2σ)
I happen to know that c2 should be 1/2, but don't see a way to give sage enough information to prove it out.
This isn't my main difficulty however. I'll just substitute it manually for now...
sage: eq1 = eq1.substitute(c2 = 1/2)
sage: eq1
∫PDF(x,μ,σ)dx=12erf(−√2μ2σ+√2x2σ)+12
This is the solution found on wikipedia:
sage: eq2 = integrate(PDF, x) == 1/2 * (1 + erf((x - mu)/(sigma * sqrt(2))))
sage: eq2
∫PDF(x,μ,σ)dx=12erf(−√2(μ−x)2σ)+12
I'd like to prove that the solution given by sage is the same as given by wikipedia (rather than eyeballing it).
sage: equality = (eq1.right() == eq2.right())
sage: equality
12erf(−√2μ2σ+√2x2σ)+12=12erf(−√2μ−√2x2σ)+12
I believe this equation is trivially True, but I'd like sage to tell me that.
The simplify() function doesn't help me do it:
sage: simplify(equality)
12erf(−√2μ2σ+√2x2σ)+12=−12erf(√2μ−√2x2σ)+12
solve(,x) does however get me significantly closer:
sage: equality = solve(equality, x)[0]
sage: equality
erf(−√2μ−√2x2σ)=erf(−√2μ−√2x2σ)
The forms on both sides are exactly the same, can't sage reduce this directly to True from here?
The next step in the solution would be to inverse-erf both sides of the equation.
How come sage doesn't know that? How can I tell it?
I'll try to force it by running the inverse-erf function on the equation.
I couldn't find such a function, but I can get sage to give me one:
sage: var('x y')
sage: inverse_erf = solve(erf(x) == y, x)
sage: inverse_erf
[x=inverseerf(y)]
sage: inverse_erf = inverse_erf[0].right().operator()
sage: inverse_erf
inverseerf
This doesn't work the way I had hoped...
Why doesn't the `inverse_erf()` function distribute itself across the equation?
sage: inverse_erf(equality)
inverseerf(erf(−√2μ−√2x2σ)=erf(−√2μ−√2x2σ))
It doesn't even work in the most basic case, so maybe I've completely gone off the rails?
sage: simplify(inverse_erf(erf(x)))
inverseerf(erf(x))
In summary: What have I done wrong, and how can I do it better?