Entity: MathLib 417 61 null * ix int 3 false false true iy int 3 false false true iz int 3 false false true Operation: pi MathLib double query static true result = 3.14159265 Operation: e MathLib double query static true result = 1->exp() Operation: setSeeds MathLib void x int y int z int static true ix = x & iy = y & iz = z Operation: nrandom MathLib double query static true ix = ( ix@pre * 171 ) mod 30269 & iy = ( iy@pre * 172 ) mod 30307 & iz = ( iz@pre * 170 ) mod 30323 & result = ( ix / 30269.0 + iy / 30307.0 + iz / 30323.0 ) Operation: random MathLib double query static true r = MathLib.nrandom() & result = ( r - r.floor ) Operation: combinatorial MathLib long n int m int query static cached n >= m & m >= 0 ( n - m < m => result = Integer.Prd(m + 1,n,i,i) / Integer.Prd(1,n - m,j,j) ) & ( n - m >= m => result = Integer.Prd(n - m + 1,n,i,i) / Integer.Prd(1,m,j,j) ) Operation: factorial MathLib long x int query static cached true ( x < 2 => result = 1 ) & ( x >= 2 => result = Integer.Prd(2,x,i,i) ) Operation: gcd MathLib int x int y int query static x >= 1 & y >= 1 true Operation: lcm MathLib int x int y int query static x >= 1 & y >= 1 result = ( x * y ) / MathLib.gcd(x,y) Activity: MathLib gcd l : int ; k : int ; l := x ; k := y ; while l /= 0 & k /= 0 do if l < k then k := k mod l else l := l mod k ; if l = 0 then return k else return l Operation: integrate MathLib double f Sequence(double) d double query static f.size >= 1 & d >= 1 result = d*(f.subrange(2, f.size - 1)->sum()) + d*(f.first + f.last)/2.0 Operation: asinh MathLib double x double query static true result = (x + (x*x + 1)->sqrt())->log() Operation: acosh MathLib double x double query static x >= 1 result = (x + (x*x - 1)->sqrt())->log() Operation: atanh MathLib double x double query static x /= 1 result = 0.5*((1+x)/(1-x))->log() Operation: isPrime MathLib boolean x int query static true ( x <= 1 => result = false ) & ( x = 2 => result = true ) & ( x > 2 => result = Integer.subrange(2,x.sqrt.floor)->forAll( i | x mod i > 0 ) ) Operation: coprime MathLib boolean x int y int query static x > 0 & y > 0 (x = 1 => result = true) & (y = 1 => result = true) & (x > 1 & x = y => result = false) & (x /= y & MathLib.gcd(x,y) = 1 => result = true) & (true => result = false) Activity: MathLib isPrime if x < 2 then return false else skip ; if x = 2 then return true else skip ; b : int := x.sqrt.floor ; i : int := 2 ; while i <= b do if x mod i = 0 then return false else i := i + 1 ; return true GeneralUseCase: testprimes false Constraint: null true MathLib.isPrime(911)->display() null testprimes false Constraint: null true MathLib.isPrime(70771)->display() null testprimes false