How to find solution

35 views
Skip to first unread message

Santanu Sarkar

unread,
Oct 14, 2017, 12:38:45 PM10/14/17
to sage-support
In Sage, is it possible to find a such that

 \int_{a}^{\infty} e^(-x^2/2) dx=2^(-20)

Simon King

unread,
Oct 14, 2017, 4:06:44 PM10/14/17
to sage-s...@googlegroups.com
Hi!

On 2017-10-14, Santanu Sarkar <sarkar.sa...@gmail.com> wrote:
> In Sage, is it possible to find a such that
>
> \int_{a}^{\infty} e^(-x^2/2) dx=2^(-20)

Yes.

Probably you want to see how.


First, define a variable `a`. I don't know if one really needs
to declare its domain to solve the problem, but when one does,
the computation works:

sage: var('a', domain='real')
a

Compute the integral (which relies on the error function):

sage: F = (e^(-x^2/2)).integral(x,a,infinity)
sage: F
-1/2*sqrt(2)*sqrt(pi)*erf(1/2*sqrt(2)*a) + 1/2*sqrt(2)*sqrt(pi)

Solve for `a`. I want the solution to be given as a list of
dictionaries:

sage: LD = solve(F==2^(-20), a, solution_dict=True)

The solution is unique and is given in terms of the inverse of
the error function:

sage: len(LD)
1
sage: LD[0][a]
sqrt(2)*erfinv(-1/1048576*sqrt(2)/sqrt(pi) + 1)

You can evaluate it numerically, and then verify it's correct:

sage: a_num = RR(LD[0][a]); a_num
4.94513221771782
sage: RR((e^(-x^2/2)).integral(x,a_num,infinity)) - 2.^-20
0.000000000000000

Regards,
Simon


Simon King

unread,
Oct 15, 2017, 4:00:58 AM10/15/17
to sage-s...@googlegroups.com
On 2017-10-14, Simon King <simon...@uni-jena.de> wrote:
> First, define a variable `a`. I don't know if one really needs
> to declare its domain to solve the problem, but when one does,
> the computation works:

One doesn't need to. var('a') is just fine.

Santanu Sarkar

unread,
Oct 18, 2017, 8:45:32 AM10/18/17
to sage-support
Dear Simon,
    Thank you so much.

Regards,
Santanu


--
You received this message because you are subscribed to the Google Groups "sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscribe@googlegroups.com.
To post to this group, send email to sage-s...@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages