Ask Your Question

evaluating inverse erf

asked 2011-05-18 03:22:39 -0500

RossK gravatar image

updated 2011-05-18 05:41:22 -0500

kcrisman gravatar image

Hi - The code below results in an expression, y, involving the inverse erf function i.e. exp(sqrt(2) inverse_erf(1/2)) which is approximately 1.96 according to another mathematical package. I tried to get a numerical value for y using y.n() but that crashes. Can anyone please advise how to evaluate such symbolic expressions?

PDF = exp(-x^2 /2)/sqrt(2*pi)
integralExpr = integrate(PDF,x,z,oo).subs(z==log(t))
y = solve(integralExpr==z,t)[0].rhs().subs(z==1/4)    
edit retag flag offensive close merge delete

1 answer

Sort by » oldest newest most voted

answered 2011-05-18 07:52:35 -0500

kcrisman gravatar image

updated 2011-05-18 07:53:08 -0500

This is something relatively new to Sage, via Maxima. See this Maxima devel post for details.

What this means is that we have yet to implement this conversion in Sage - not surprising, since it doesn't seem to be in Ginac. (In fact, erf doesn't even seem to be in Ginac!)

However, it is in mpmath.

sage: e^(sqrt(2)*RR(mpmath.erfinv(1/2))).n()

Unfortunately, the typical beginning user might not know the RR trick. There are two things we need to do for this.

  • Have a symbolic inverse erf function, which we do not yet have.
  • Make a ._sage_() method for mpmath numbers, or make it easier to figure out how to get them symbolic. There is also no .n() method. I shouldn't have to to this if I forget RR!

    sage: e^(sqrt(2)*sage.libs.mpmath.all.mpmath_to_sage(mpmath.erfinv(1/2),53)).n()


This reminds me that askbot has still not fixed the issue of formatting after bullets (which, to be fair, was upstream from them...)

edit flag offensive delete link more


Implementing this natively in Sage is now

kcrisman gravatar imagekcrisman ( 2011-05-18 08:00:18 -0500 )edit

Thanks for the answer (I have something to work with now) and for creating the ticket!

RossK gravatar imageRossK ( 2011-05-18 17:22:31 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


Asked: 2011-05-18 03:22:39 -0500

Seen: 1,141 times

Last updated: May 18 '11