7.4 Arithmetic Functions and Relations

The following arithemetic functions are available.

Num1 + Num2

Returns the sum of Num1 and Num2.
fun nat + nat -> nat, int + int -> int, num + num -> num

Num1 - Num2

Returns the difference of Num1 and Num2.
fun int - int -> int, num - num -> num

-Num1

Returns the negative value of Num.
fun -(int) -> int, -(num) -> num

Num1 * Num2

Returns the product of Num1 and Num2.
fun nat * nat -> nat, int * int -> int, num * num -> num

Num1 // Num2

Returns the integer division of Num1 and Num2.
fun //(nat, nat) -> nat, //(int, int) -> int

Num1 / Num2

Returns the division of Num1 and Num2.
fun num / num -> num

Num1 mod Num2

Returns the mod of Num1 and Num2.
fun int mod int -> int

Num1 ** Num2

Returns Num1 raised to the power Num2.
fun nat ** nat -> nat, int ** int -> int, num ** num -> num

Int >> Nat

Returns the bitwise right shift of Int with respect to Nat.
>>: (int, nat) -> int

Int << Nat

Returns the bitwise left shift of Int with respect to Nat.
fun int << nat -> int

Int1 /\ Int2

Returns the bitwise AND of Int1 and Int2.
fun int /\ int -> int

Int1 \/ Int2

Returns the bitwise OR of Int1 and Int2.
fun int \/ int -> int

\ Int

Returns the bitwise complement of Int.
fun \(int) -> int

abs(Num)

Returns the absolute value of Num.
fun abs(int) -> nat, abs(num) -> num

sqrt(Num)

Returns the square root of Num.
fun sqrt(num) -> num

round(Num)

Returns the nearest integer to Num.
fun round(num) -> int

floor(Num)

Returns the greatest integer less than Num.
fun floor(num) -> int

ceiling(Num)

Returns the smallest number greater than Num.
fun ceiling(num) -> int

pi()

Returns value 3.14159 for PI.
fun pi() -> num

e()

Returns 2.71828 value for E.
fun e() -> num

sin(Num)

Returns the sin of Num.
fun sin(num) -> num

cos(Num)

Returns the cos of Num.
fun cos(num) -> num

tan(Num)

Returns the tan of Num.
fun tan(num) -> num

asin(Num)

Returns the arcsin of Num.
fun asin(num) -> num

acos(Num)

Returns the arccos of Num.
fun acos(num) -> num

atan(Num)

Returns the arctan of Num.
fun atan(num) -> num

atan2(Y, X)

Returns the atan2 of Y and X. This returns an angle in the range (-pi, pi].
fun atan2(num,num) -> num

Note that some of the above function calls can raise an exception - for example:

| ?? X = 1/0.

QuLog exception - exception term: arithmetic_function_domain_error(1 / 0)

On This Site