Loading [MathJax]/jax/output/HTML-CSS/jax.js

First time here? Check out the FAQ!

Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

solve equation of erf

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?

click to hide/show revision 2
No.2 Revision

solve equation of erf

I used @ndomes' method of using numeric functions, which solved my 1/2 issue above, but I still wind up unable to prove that erf... == erf.... What's going on here??

sage: var('x sigma mu')
sage: assume(sigma > 0)
sage: eq3 = (-erf(sqrt(2)*mu - sqrt(2)*x) == -erf(sqrt(2)*(mu - x)))
sage: show(eq3)
sage: show(bool(eq3))
sage: eq3 = (-erf((sqrt(2)*mu - sqrt(2)*x)/(2*sigma)) == -erf((sqrt(2)*(mu - x))/(2*sigma)))
sage: show(eq3)
sage: show(bool(eq3))

erf(2μ2x)=erf(2(μx))

True

erf(2μ2x2σ)=erf(2(μx)2σ)

False



Original post:

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?


click to hide/show revision 3
No.3 Revision

solve equation of erf

I used @ndomes' method of using numeric functions, which solved my 1/2 issue above, but I still wind up unable to prove that erf... == erf.... What's going on here??

sage: var('x sigma mu')
sage: assume(sigma > 0)
sage: eq3 = (-erf(sqrt(2)*mu - sqrt(2)*x) == -erf(sqrt(2)*(mu - x)))
sage: show(eq3)
sage: show(bool(eq3))
sage: eq3 = (-erf((sqrt(2)*mu - sqrt(2)*x)/(2*sigma)) == -erf((sqrt(2)*(mu - x))/(2*sigma)))
sage: show(eq3)
sage: show(bool(eq3))

erf(2μ2x)=erf(2(μx))

True

erf(2μ2x2σ)=erf(2(μx)2σ)

False



Original post:

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?


click to hide/show revision 4
No.4 Revision

solve equation of erf

I used @ndomes' method of using numeric functions, but I still wind up unable to prove that erf... == erf.... What's going on here??:

sage: var('x sigma mu')
sage: assume(sigma > 0)
sage: eq3 = (-erf(sqrt(2)*mu - sqrt(2)*x) == -erf(sqrt(2)*(mu - x)))
sage: show(eq3)
sage: show(bool(eq3))
sage: eq3 = (-erf((sqrt(2)*mu - sqrt(2)*x)/(2*sigma)) == -erf((sqrt(2)*(mu - x))/(2*sigma)))
sage: show(eq3)
sage: show(bool(eq3))

erf(2μ2x)=erf(2(μx))

True

sage: eq3 = (-erf((sqrt(2)*mu - sqrt(2)*x)/(2*sigma)) == -erf((sqrt(2)*(mu - x))/(2*sigma)))
sage: show(eq3)
sage: show(bool(eq3))

erf(2μ2x2σ)=erf(2(μx)2σ)

False


What's going on here?? Is it related to being unable to reduce inverse_erf(erf()) below?

sage: solve(erf(x) == erf(y), x)[0].simplify_full()
x == inverse_erf(erf(y))

solve equation of erf

I used @ndomes' method of using numeric functions, but I still wind up unable to prove that erf... == erf...:

sage: var('x sigma mu')
sage: assume(sigma > 0)
sage: eq3 = (-erf(sqrt(2)*mu - sqrt(2)*x) == -erf(sqrt(2)*(mu - x)))
sage: show(eq3)
sage: show(bool(eq3))

erf(2μ2x)=erf(2(μx))

True

sage: eq3 = (-erf((sqrt(2)*mu - sqrt(2)*x)/(2*sigma)) == -erf((sqrt(2)*(mu - x))/(2*sigma)))
sage: show(eq3)
sage: show(bool(eq3))

erf(2μ2x2σ)=erf(2(μx)2σ)

False


What's going on here?? Is it related to being unable to reduce inverse_erf(erf()) below?

sage: solve(erf(x) == erf(y), x)[0].simplify_full()
x == inverse_erf(erf(y))
click to hide/show revision 6
No.6 Revision

solve equation of erf

I used @ndomes' method of using numeric functions, but I still wind up unable to prove that erf... == erf...:

sage: var('x sigma mu')
sage: assume(sigma > 0)
sage: eq3 = (-erf(sqrt(2)*mu - sqrt(2)*x) == -erf(sqrt(2)*(mu - x)))
sage: show(eq3)
sage: show(bool(eq3))

erf(2μ2x)=erf(2(μx))

True

sage: eq3 = (-erf((sqrt(2)*mu - sqrt(2)*x)/(2*sigma)) == -erf((sqrt(2)*(mu - x))/(2*sigma)))
sage: show(eq3)
sage: show(bool(eq3))

erf(2μ2x2σ)=erf(2(μx)2σ)

False


This slightly simpler equation works correctly however:

sage: eq4 = (-erf((sqrt(2)*mu - sqrt(2)*x)/(sigma)) == -erf((sqrt(2)*(mu - x))/(sigma)))
sage: show(eq4)
sage: show(bool(eq4))

erf(2μ2xσ)=erf(2(μx)σ)

True


What's going on here?? Is it related to being unable to reduce inverse_erf(erf()) below?

sage: solve(erf(x) == erf(y), x)[0].simplify_full()
x == inverse_erf(erf(y))

solve equation of erf

I used @ndomes' method of using numeric functions, but I still wind up unable to prove that erf... == erf...:

sage: var('x sigma mu')
sage: assume(sigma > 0)
sage: eq3 = (-erf((sqrt(2)*mu - sqrt(2)*x)/(2*sigma)) == -erf((sqrt(2)*(mu - x))/(2*sigma)))
sage: show(eq3)
sage: show(bool(eq3))

erf(2μ2x2σ)=erf(2(μx)2σ)

False


This slightly simpler equation works correctly however:

sage: eq4 = (-erf((sqrt(2)*mu - sqrt(2)*x)/(sigma)) == -erf((sqrt(2)*(mu - x))/(sigma)))
sage: show(eq4)
sage: show(bool(eq4))

erf(2μ2xσ)=erf(2(μx)σ)

True


What's going on here?? Is it related to being unable to reduce inverse_erf(erf()) below?

sage: solve(erf(x) == erf(y), x)[0].simplify_full()
x == inverse_erf(erf(y))

solve equation of erf

I used @ndomes' method of using numeric functions, but I still wind up unable to prove that erf... == erf...:

sage: var('x sigma mu')
sage: assume(sigma > 0)
sage: eq3 = (-erf((sqrt(2)*mu - sqrt(2)*x)/(2*sigma)) == -erf((sqrt(2)*(mu - x))/(2*sigma)))
sage: show(eq3)
sage: show(bool(eq3))

erf(2μ2x2σ)=erf(2(μx)2σ)

False


This slightly simpler equation works correctly however:

sage: eq4 = (-erf((sqrt(2)*mu - sqrt(2)*x)/(sigma)) == -erf((sqrt(2)*(mu - x))/(sigma)))
sage: show(eq4)
sage: show(bool(eq4))

erf(2μ2xσ)=erf(2(μx)σ)

True


What's going on here?? Is it related to being unable to reduce inverse_erf(erf()) below?

sage: solve(erf(x) == erf(y), x)[0].simplify_full()
x == inverse_erf(erf(y))