| ||||||||||||||||||
Functions Available
UltimaCalc supports user-defined functions.
Of course, it has the usual arithmetic operations
of + - * /
It also has the following:
^ or ** - the exponentiation operator,
or power function. For example 2^3 is equivalent to 23
and evaluates to 8. Note that if X is negative,
X^Y will fail if Y is not an integer. Special treatment
is given when Y is an integer, in order to maximise precision.
For
example, 83521*83521*83521*83521*83521*83521*83521-17^28 evaluates to
precisely zero. The case of 0^N should be noted. If N
is greater than zero, the expression evaluates to zero. If N is less
than zero, the value is undefined, and if N is precisely zero, the
expression is given the value 1.
! - the factorial operator, for example 5! evaluates
to 120. (The factorial operator converts the number to an integer first, if necessary.)
perm(n, r) returns the number of permutations of n items
taken r at a time, or n!/(n-r)!
comb(n, r) returns the number of combinations of n items
taken r at a time, or n!/r!/(n-r)!
gcd(x1, x2) returns the Greatest Common Divisor of x1
and x2. If either argument is zero, this function returns
the other argument, and gcd(0, 0) is defined as 0.
mod(x1, x2) returns the remainder when x1 is divided by x2.
prime(n) returns the nth
prime number, The maximum value of n depends on how
many primes UltimaCalc knows, which can be up to a maximum of just over 200,000,000.
factor(x) returns the smallest (prime) factor of x,
provided that this factor is no greater than the largest prime number known to
UltimaCalc (see prime). If x is 0
or 1, factor(x) returns 0
or 1 respectively, and it returns x if
x is prime. If x is negative, the
returned result is also negative.
The value of pi, the ratio of a circle’s circumference to its diameter (= 3.14159…),
is available by typing pi or PI. See constants.
Algebraic Functions
sqr(x) and sqrt(x) are identical. They return the square
root of x if this is not negative.
cubrt(x) returns the cube root of x even if this is negative.
The expression x^(1/3) also calculates cube roots, but it fails if x is negative
and may be slightly less accurate than cubrt due to having to use a much more complex internal
calculation which involve a logarithm followed by an exponential. For example, cubrt(27)-3
evaluates to 0, whereas 27^(1/3)-3 evaluates to -1.2e-38.
ln(x) and log(x) return the logarithm of x
(to base e = 2.718281828...). This is sometimes called the natural logarithm.
log10(x) returns the logarithm of x to base 10. This function is also known as the 'common' logarithm.
lg(x) and log2(x) return the logarithm of x to base 2.
exp(x) returns the exponential function of x.
Trigonometric Functions
sin(x), cos(x), tan(x)
are the usual sine, cosine and tangent functions. The argument x
can be in degrees or radians, as selected from the menu.
asin(x) and arcsin(x) return the inverse sine of x in
the range –90° to +90° (–pi/2 to pi/2).
acos(x) and arccos(x) return the inverse cosine of x
in the range 0° to +180° (0 to pi).
atan(x) and arctan(x) return the inverse tangent of x
in the range –90° to +90° (–pi/2 to pi/2).
atan2(x, y) returns the inverse tangent of (y/x)
in the range –180° to +180° (–pi to pi).
The value of x is allowed to be 0 provided that y
is not also 0.
cosec(x) and csc(x) are equivalent to 1/sin(x).
sec(x) is equivalent to 1/cos(x).
cot(x) is equivalent to 1/tan(x).
acsc(x), acosec(x), arccsc(x) and arccosec(x) return the inverse cosecant of x, which is the inverse sine of 1/x.
asec(x) and arcsec(x) return the inverse secant of x, which is the inverse cosine of 1/x.
acot(x) and arccot(x) return the inverse contangent of x, which is the inverse tangent of 1/x.
Hyperbolic Functions
sinh(x), cosh(x), tanh(x)
and asinh(x), acosh(x), atanh(x)
are the hyperbolic sine, cosine and tangent functions and their inverses.
cosech(x), and csch(x), are equivalent to 1/sinh(x).
sech(x) is equivalent to 1/cosh(x).
coth(x) is equivalent to 1/tanh(x).
asinh(x) and arcsinh(x) return the inverse sinh of x.
acosh(x) and arccosh(x) return the inverse cosh of x.
atanh(x) and arctanh(x) return the inverse tanh of x.
acsch(x), acosech(x), arccsch(x) and arccosech(x) return the inverse cosech of x, which is the inverse sinh of 1/x.
asech(x) and arcsech(x) return the inverse sech of x, which is the inverse cosh of 1/x.
acoth(x) and arccoth(x) return the inverse coth of x, which is the inverse tanh of 1/x.
Tests and Comparisons
>, >=, <, <=,
==, and <> compare the values on either side and return 1 if the first
value, compared to the second, is greater, greater or equal, less than, less than or equal, equal, or
not equal, respectively. The 'equality' test accepts as equal two numbers which are within about two
least significant calculated digits of each other, or which are both zero.
if(test, expr1, expr2) is a 'function' that takes two or three arguments.
First, the test expression is evaluated. Then, if the result is non-zero, the value of
expr1 is computed and returned. Otherwise, the value of expr2 is
computed and returned. If the expression expr2 is omitted, it is taken to
be 0.
Example:
The expression if(x==0, 1, sin(x)/x) evaluates sin(x)/x correctly even when x is 0.
Miscellaneous
min(x1, x2, ...) and max(x1, x2, ...) are
functions that take one or more arguments, evaluate each in turn from left to
right, and return the smallest (or largest) of the calculated values.
minimum(expression, symbol, start, end) returns the value of the symbol
at which the value of the expression is at its minimum. For example, minimum(sin(x), x, 0, 2*pi)
finds the value of x in the range from 0 to 2*pi for which sin(x)
has its minimum value. The calculated result is approximately 1.5*pi. The accuracy can not be
expected to be better than the square root of the precision of the calculation engine, i.e. not better than
19 digits
frac(x) returns the fractional part of a number. For
example, frac(3.14) evaluates to 0.14
int(x) returns the value of x rounded to the nearest whole number. So
if x>=0, then int(x) returns the integer part of x+0.5,
and if x<0, then int(x) returns the integer part of x-0.5.
floor(x) returns the largest integer which is not greater
than x. For example, floor(3.1) returns 3 whereas
floor(-3.1) returns -4
ceil(x) (ceiling) returns the smallest integer which is no less than
x. For example, ceil(3.1) returns 4 whereas ceil(-3.1)
returns -3.
abs(x) returns the absolute value of x, for example abs(-3.1)
is 3.1.
angle(x1, y1, x2, y2) Given a line passing through the two points (x1, y1) and (x2, y2), this function returns the angle at which this line intercepts the X-axis. This angle is in the range –90° to +90° (–pi/2 to pi/2).
And also check out polynomial roots and integration.
