Euclid
 Home Download Register Known Issues Bug Report Operators Expressions Functions Constants Variables Built-in Functions Types Commands Other Products Contact Kevin's Home Page Euclid has lots of built-in functions. You can use these in expressions just like your user-defined functions. sqrt(x) Evaluates to the square root of x. LIMITATIONS: Currently, sqrt only supports positive rational numbers. It does not support irrational inputs, or negative inputs (which would result in complex numbers). floor(x) Evaluates to the floor of x, which is the largest integer less than or equal to x. For example, floor(2.3) = 2. floor(-2.3) = -3. ceiling(x) Evaluates to the ceiling of x, which is the smallest integer greater than or equal to x. For example, ceiling(2.3) = 3. ceiling(-2.3) = -2. abs(x) Evaluates to the absolute value of x. For example, abs(2.3) = 2.3. abs(-2.3) = 2.3. choose(n, k) Evaluates to (n choose k), where and k are integers. (n choose k) is equivalent to (n! / ((n-k)! * k!). partition(x) Returns partition function of x, which is the number of ways the positive integer x can be represented as the sum of positive integers. partition(4) = 5, since 4 = 4, 3 + 1, 2 + 2, 2 + 1 + 1, and 1 + 1 + 1 + 1 digitCount(x) Returns the number of digits in x, where x is an integer. digitCount(2010) == 4. sigma({expr(x)}, a, b) sigma behaves like the sigma used in mathematic expressions. It evaluates to the sum of an expression over a range of integers. The expression should be an expression of x, where x is to be replaced by the integers from a to b, inclusive. sigma(x*x, 1, 4) = 1 + 4 + 9 + 16 = 30 If f(x) = 1 / x, then sigma(f(x), 1, 3) = 1 + 1/2 + 1/3 = 1 + 5/6. evalInterval({expr(x)}, a, b) evalInterval is similar to the sigma function. It evaluates an expression over a range of integers, printing the results for each computation. The expression should be an expression of x, where x is to be replaced by the integers from a to b, inclusive. random(min, max, granularity) random returns a random number from min to max, inclusive, with the given granularity. For example, random(1, 4, 1.0) will return the numbers 1, 2, 3, or 4 (with equal probability. random(1, 3, 0.5) will return the numbers 1.0, 1.5, 2.0, 2.5, or 3.0 with equal probability. fibonacci(n) Returns the nth Fibonacci number, where fibonacci(1) = fibonacci(2) = 1, and fibonacci(n) = fibonacci(n - 1) + fibonacci(n - 2). compare(a, b) Returns -1 if a < b, 0 if a == b, or 1 if a > b. max(a, b) Returns a if a > b, else it returns b. min(a, b) Returns a if a < b, else it returns b. isPerfectSquare(n) Returns 1 if the number is a perfect square, 0 otherwise. In other words, returns 1 if there exists some integer x such that x^2 = n. Trigonometric functions: sin(x), cos(x), tan(x), sec(x), csc(x), cot(x), arcsin(x), arccos(x), arctan(x), arcsec(x), arccsc(x), arccot(x) Returns the specified trigonometric function: sine, cosine, tangent, secant, cosecant, cotant, arcsine, arccosine, arctangent, arcsecant, arccosecant, and arccotangent, respectively. Only radian arguments are currently accepted. Degree arguments are not currently supported. NOTE: Currently, arccos, arcsec, arccsc, and arccot do not work. Bitwise functions: countBits(x), setBit(x, b), clearBit(x, b), toggleBit(x, b), lowestSetBit(x), testBit(x, b) Common bitwise operations. b, the bit argument, is 0-based (the 0th bit is the least significant bit). graph({expr(x)}, a, b) Opens a new window with a graph of the expression, evaluated from x = a to x = b. solve({expr(x)}) Finds the value of x that makes the expression equal to 0. Currently only works for simple linear expressions, such as solve(5 * x + 4). Logarithm Functions Primality and Factorization Functions Set Functions Matrix Functions

Euclid
Copyright © 2003-2006 Kevin L. Gong