Problem recreating example of normal distribution from TI-Nspire [closed]

I have to recreate this formula for calculating normal distribution in Sage:

http ://ntaj.dreamhosters.com/ti.jpg

The picture is from TI-Nspire CAS.

What I'm doing is:

sage: f=1/(0.1sqrt(2pi)) * e^((-1/2)*((x-4)/0.1))^2

sage: float(integral(f, 3.9, 4.1))

0.8696735925295498

I can't get the expected result 0.682689 that Nspire gives. Can anyone see why?

edit retag reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by Ross1856 close date 2017-04-28 11:24:30.118994

Sort by ยป oldest newest most voted

You did not get the expected result because the last ^2 is ill placed; it should be inside the parentheses:

sage: f = 1/(0.1*sqrt(2*pi)) * e^((-1/2)*((x-4)/0.1)^2)


Then

sage: numerical_integral(f, 3.9, 4.1)
(0.6826894921370853, 7.579375928402468e-15)


(the second number is an evaluation of the numerical error).

more

Pari/gp delivers:

? s = 0.1;

? intnum( x=3.9, 4.1, exp( -(x-4)^2/2/s^2 ) / sqrt(2*Pi*s^2) )
%2 = 0.6826894921370858971704650911


We can do the same in sage, i.e. call gp:

sage: gp( "intnum( x=3.9, 4.1, exp( -(x-4)^2/2/%s^2 ) / sqrt(2*Pi)/%s)" % ( 0.1, 0.1 ) )
0.6826894921370858971704650911


Or call the numerical integral from sage:

sage: integral_numerical( lambda x :    exp( -(x-4)^2/2/0.1^2 ) / sqrt(2*pi)/0.1, 3.9, 4.1 )
(0.6826894921370853, 7.579375928402468e-15)


which computes the approximative value 0.6826894921370853 with an error less than $7,6\cdot 10^{-15}$, as given in the second argument.

more