The maths
scope contains mathematical functions and constants.
import maths
OR
import Maths
The mathematical constant π (pi).
Name | Description |
---|---|
PI | The value of π (pi). |
The mathematical constant e.
Name | Description |
---|---|
E | The value of e. |
Adds two numbers together.
Name | Description |
---|---|
first | The first number to add. |
second | The second number to add. |
The result of adding first
and second
.
result = maths.add(5, 3)
# Result: 8
Subtracts one number from another.
Name | Description |
---|---|
first | The number to subtract from. |
second | The number to subtract. |
The result of subtracting second
from first
.
result = maths.sub(10, 4)
# Result: 6
Multiplies two numbers together.
Name | Description |
---|---|
first | The first number to multiply. |
second | The second number to multiply. |
The result of multiplying first
and second
.
result = maths.mul(7, 3)
# Result: 21
Divides one number by another.
Name | Description |
---|---|
first | The number to be divided. |
second | The divisor. |
The result of dividing first
by second
.
result = maths.div(15, 3)
# Result: 5
Raises a base number to a given exponent.
Name | Description |
---|---|
base | The base number. |
exponent | The exponent to raise to. |
The result of raising base
to the power of exponent
.
result = maths.pow(2, 3)
# Result: 8
Calculates the square root of a number.
Name | Description |
---|---|
number | The number to calculate the square root of. |
The square root of number
.
result = maths.sqrt(25)
# Result: 5
Calculates the modulus (remainder) of a number.
Name | Description |
---|---|
number | The number to find the modulus of. |
The modulus of number
.
result = maths.mod(10, 3)
# Result: 1
Calculates the natural logarithm of a value.
Name | Description |
---|---|
value | The value to calculate the natural logarithm of. |
The natural logarithm of value
.
result = maths.ln(2.71828)
# Result: 1.0
Calculates the base 10 logarithm of a value.
Name | Description |
---|---|
value | The value to calculate the base 10 logarithm of. |
The base 10 logarithm of value
.
result = maths.log10(100)
# Result: 2.0
Calculates the exponential value of a given exponent.
Name | Description |
---|---|
exponent | The exponent to calculate the exponential value of. |
The exponential value of exponent
.
result = maths.exp(2)
# Result: 7.38905609893
Calculates the absolute value of a number.
Name | Description |
---|---|
number | The number to calculate the absolute value of. |
The absolute value of number
.
result = maths.abs(-5)
# Result: 5
Rounds a number to the nearest integer.
Name | Description |
---|---|
number | The number to be rounded. |
The rounded integer value of number
.
result = maths.round(3.7)
# Result: 4
Calculates the sine of an angle.
Name | Description |
---|---|
angle | The angle in radians for which to calculate the sine. |
The sine of angle
.
result = maths.sin(0.5)
# Result: 0.4794255386
Calculates the cosine of an angle.
Name | Description |
---|---|
angle | The angle in radians for which to calculate the cosine. |
The cosine of angle
.
result = maths.cos(0.5)
# Result: 0.87758256189
Calculates the tangent of an angle.
Name | Description |
---|---|
angle | The angle in radians for which to calculate the tangent. |
The tangent of angle
.
result = maths.tan(0.5)
# Result: 0.54630248984
Calculates the arcsine of a value.
Name | Description |
---|---|
value | The value for which to calculate the arcsine. |
The arcsine of value
.
result = maths.asin(0.5)
# Result: 0.52359877559
Calculates the arccosine of a value.
Name | Description |
---|---|
value | The value for which to calculate the arccosine. |
The arccosine of value
.
result = maths.acos(0.5)
# Result: 1.0471975512
Calculates the arctangent of a value.
Name | Description |
---|---|
value | The value for which to calculate the arctangent. |
The arctangent of value
.
result = maths.atan(0.5)
# Result: 0.463647609
Calculates the secant of an angle.
Name | Description |
---|---|
angle | The angle in radians for which to calculate the secant. |
The secant of angle
.
result = maths.sec(0.5)
# Result: 1.13949392732
Calculates the cosecant of an angle.
Name | Description |
---|---|
angle | The angle in radians for which to calculate the cosecant. |
The cosecant of angle
.
result = maths.csc(0.5)
# Result: 2.08582964293
Calculates the cotangent of an angle.
Name | Description |
---|---|
angle | The angle in radians for which to calculate the cotangent. |
The cotangent of angle
.
result = maths.cot(0.5)
# Result: 1.83048772171
Calculates the hyperbolic sine of an angle.
Name | Description |
---|---|
angle | The angle in radians for which to calculate the hyperbolic sine. |
The hyperbolic sine of angle
.
result = maths.sinh(0.5)
# Result: 0.52109530549
Calculates the hyperbolic cosine of an angle.
Name | Description |
---|---|
angle | The angle in radians for which to calculate the hyperbolic cosine. |
The hyperbolic cosine of angle
.
result = maths.cosh(0.5)
# Result: 1.12762596521
Calculates the hyperbolic tangent of an angle.
Name | Description |
---|---|
angle | The angle in radians for which to calculate the hyperbolic tangent. |
The hyperbolic tangent of angle
.
result = maths.tanh(0.5)
# Result: 0.46211715726