EasyManua.ls Logo

Texas Instruments TI-92+ - [6.20] Generating Random Numbers

Texas Instruments TI-92+
507 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
6.2198 3198 5865 6 E-16t = 8 to t = 9
1.2791 9044 7828 2 E-12t = 7 to t = 8
9.8530 7832 4938 2 E-10t = 6 to t = 7
3.8566 4984 2341 4 E-7t = 5 to t = 6
3.1384 5902 6124 E-5t = 4 to t = 5
0.0013 1822 6789 7969t = 3 to t = 4
0.0214 0023 3916 549t = 2 to t = 3
0.1359 0512 1983 28t = 1 to t = 2
IntegralIntegration limits
Summing these individual integrals gives a result of 0.1586 5525 3931 46, which has an error of zero,
to 14 digits.
Note that I stopped taking integrals when the individual integral is less than 1E-14, since further,
smaller integrals will not contribute to the sum.
This method can be used with the á operator, or with the nInt() function.
The function nintx(), shown below, automates this process.
nintx(ffx,xv,xx1,xx2,nx)
func
©Numerical integrator with summed subintervals
©dburkett@infinet.com 6 nov 99
©ffx: function to integrate
©xv: variable of integration
©xx1,xx2: lower and upper integration limits
©nx: number of subintervals
local dx
(xx2-xx1)/nxdx
sum(seq(nint(ffx,xv,xx1+i*dx,xx1+(i+1)*dx),i,0,nx-1))
endfunc
For example, the call nintx(tan(x),x,0,1.5707,5) integrates tan(x) from x=0 to x=1.5707, with 5
subintervals.
The amount of improvement depends on the function. The built-in nint() function has an error of
-29.7E-12 for the tan(x) example above. nintx() with 10 intervals has an error of about 13E-12.
[6.20] Generating random numbers
The rand() function can only be used to generate random integers in the intervals [1,n] or [-n, -1]. Use
this to generate random integers over any range [nl,nh]:
rand(nh-nl+1)+nl-1
If rand() is called with no arguments, it returns a random floating point number between 0 and 1. To
generate uniformly distributed random numbers over the range [fl,fh], use this:
(fh-fl)*rand()+fl
6 - 23

Table of Contents

Related product manuals