|absolute value of Exp : i.e. Exp if Exp ≥ 0, –Exp if Exp < 0|
|arctangent (inverse tangent) of Exp : result is in radians|
|cosine of the Exp : Exp is in radians|
|eExp : e is 2.71828182845…|
|natural logarithm of Exp : i.e. logarithm to the base* e|
|sine of the Exp : Exp is in radians|
|square root of the Exp|
|tangent of the Exp: Exp is in radians|
|sign (+1 or –1) of the Exp: sign(–3) = –1 = sign(–3.7)|
|float of the Exp: float(22) = 22.0 -
see also |
|largest integer ≤ Exp: floor(1.66) = 1|
|remove fractional part of Exp: truncate(–1.5) = –1, truncate(1.5) = 1|
|round Exp to nearest integer: round(1.6) = 2, round(1.3) = 1|
|smallest integer ≥ Exp: ceiling(1.3) = 2|
These functions should be used in a context where they will actually
be evaluated, such as following
or as part of an arithmetic comparison
?- X is sqrt(2). X = 1.41421Compare this with the following, where sqrt(2) is not evaluated, because
=does not evaluate its arguments.
?- X = sqrt(2). X = sqrt(2)Another example:
?- X is log(3+2). X = 1.60944.
These mathematical functions may correspond to arity 2 built-in predicates: for example, one can do this:
?- sqrt(2, X). X = 1.41421Some versions of SWI Prolog (e.g. 5.6.47) implement many of these arity 2 predicates, but not e.g.
* High School Maths Reminder Service: if you want the logarithm to base a, divide log(Exp) by log(a). E.g. log10(X) = log(X)/log(10), and log2(X) = log(X)/log(2).