123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969 | Float64.abs:
short: absolute value
description: >
Calculates the absolute value of a number.
return:
type: 'Float64'
description: >
The absolute value of `n`.
args:
n:
type: 'Float64'
description: >
The number whose absolute value is to be computed.
example: |
assert Float64(-3.5).abs() == 3.5
Float64.acos:
short: arc cosine
description: >
Computes the arc cosine of a number.
return:
type: 'Float64'
description: >
The arc cosine of `x` in radians.
args:
x:
type: 'Float64'
description: >
The number for which the arc cosine is to be calculated.
example: |
assert Float64(0.0).acos().near(1.5707963267948966)
Float64.acosh:
short: arc hyperbolic cosine
description: >
Computes the inverse hyperbolic cosine of a number.
return:
type: 'Float64'
description: >
The inverse hyperbolic cosine of `x`.
args:
x:
type: 'Float64'
description: >
The number for which the inverse hyperbolic cosine is to be calculated.
example: |
assert Float64(1.0).acosh() == 0
Float64.asin:
short: arc sine
description: >
Computes the arc sine of a number.
return:
type: 'Float64'
description: >
The arc sine of `x` in radians.
args:
x:
type: 'Float64'
description: >
The number for which the arc sine is to be calculated.
example: |
assert Float64(0.5).asin().near(0.5235987755982989)
Float64.asinh:
short: arc hyperbolic sine
description: >
Computes the inverse hyperbolic sine of a number.
return:
type: 'Float64'
description: >
The inverse hyperbolic sine of `x`.
args:
x:
type: 'Float64'
description: >
The number for which the inverse hyperbolic sine is to be calculated.
example: |
assert Float64(0.0).asinh() == 0
Float64.atan:
short: arc tangent
description: >
Computes the arc tangent of a number.
return:
type: 'Float64'
description: >
The arc tangent of `x` in radians.
args:
x:
type: 'Float64'
description: >
The number for which the arc tangent is to be calculated.
example: |
assert Float64(1.0).atan().near(0.7853981633974483)
Float64.atan2:
short: arc tangent from 2 variables
description: >
Computes the arc tangent of the quotient of two numbers.
return:
type: 'Float64'
description: >
The arc tangent of `x/y` in radians.
args:
x:
type: 'Float64'
description: >
The numerator.
y:
type: 'Float64'
description: >
The denominator.
example: |
assert Float64.atan2(1, 1).near(0.7853981633974483)
Float64.atanh:
short: arc hyperbolic tangent.
description: >
Computes the inverse hyperbolic tangent of a number.
return:
type: 'Float64'
description: >
The inverse hyperbolic tangent of `x`.
args:
x:
type: 'Float64'
description: >
The number for which the inverse hyperbolic tangent is to be calculated.
example: |
assert Float64(0.5).atanh().near(0.5493061443340549)
Float64.cbrt:
short: cube root
description: >
Computes the cube root of a number.
return:
type: 'Float64'
description: >
The cube root of `x`.
args:
x:
type: 'Float64'
description: >
The number for which the cube root is to be calculated.
example: |
assert Float64(27.0).cbrt() == 3
Float64.ceil:
short: ceiling function
description: >
Rounds a number up to the nearest integer.
return:
type: 'Float64'
description: >
The smallest integer greater than or equal to `x`.
args:
x:
type: 'Float64'
description: >
The number to be rounded up.
example: |
assert Float64(3.2).ceil() == 4
Float64.clamped:
short: clamp a number
description: >
Returns the given number clamped between two values so that it is within
that range.
return:
type: 'Float64'
description: >
The first argument clamped between the other two arguments.
args:
x:
type: 'Float64'
description: >
The number to clamp.
low:
type: 'Float64'
description: >
The lowest value the result can take.
high:
type: 'Float64'
description: >
The highest value the result can take.
example: |
assert Float64(2.5).clamped(5.5, 10.5) == 5.5
Float64.copysign:
short: copy a number's sign
description: >
Copies the sign of one number to another.
return:
type: 'Float64'
description: >
A number with the magnitude of `x` and the sign of `y`.
args:
x:
type: 'Float64'
description: >
The number whose magnitude will be copied.
y:
type: 'Float64'
description: >
The number whose sign will be copied.
example: |
assert Float64(3.0).copysign(-1) == -3
Float64.cos:
short: cosine
description: >
Computes the cosine of a number (angle in radians).
return:
type: 'Float64'
description: >
The cosine of `x`.
args:
x:
type: 'Float64'
description: >
The angle in radians.
example: |
assert Float64(0.0).cos() == 1
Float64.cosh:
short: hyperbolic cosine
description: >
Computes the hyperbolic cosine of a number.
return:
type: 'Float64'
description: >
The hyperbolic cosine of `x`.
args:
x:
type: 'Float64'
description: >
The number for which the hyperbolic cosine is to be calculated.
example: |
assert Float64(0.0).cosh() == 1
Float64.erf:
short: error function
description: >
Computes the error function of a number.
return:
type: 'Float64'
description: >
The error function of `x`.
args:
x:
type: 'Float64'
description: >
The number for which the error function is to be calculated.
example: |
assert Float64(0.0).erf() == 0
Float64.erfc:
short: complimentary error function
description: >
Computes the complementary error function of a number.
return:
type: 'Float64'
description: >
The complementary error function of `x`.
args:
x:
type: 'Float64'
description: >
The number for which the complementary error function is to be calculated.
example: |
assert Float64(0.0).erfc() == 1
Float64.exp:
short: base-e exponentiation
description: >
Computes the exponential function $e^x$ for a number.
return:
type: 'Float64'
description: >
The value of $e^x$.
args:
x:
type: 'Float64'
description: >
The exponent.
example: |
assert Float64(1.0).exp().near(2.718281828459045)
Float64.exp2:
short: base-2 exponentiation
description: >
Computes $2^x$ for a number.
return:
type: 'Float64'
description: >
The value of $2^x$.
args:
x:
type: 'Float64'
description: >
The exponent.
example: |
assert Float64(3.0).exp2() == 8
Float64.expm1:
short: base-e exponential minus 1
description: >
Computes $e^x - 1$ for a number.
return:
type: 'Float64'
description: >
The value of $e^x - 1$.
args:
x:
type: 'Float64'
description: >
The exponent.
example: |
assert Float64(1.0).expm1().near(1.7182818284590453)
Float64.fdim:
short: positive difference
description: >
Computes the positive difference between two numbers.
return:
type: 'Float64'
description: >
The positive difference $\max(0, x - y)$.
args:
x:
type: 'Float64'
description: >
The first number.
y:
type: 'Float64'
description: >
The second number.
example: |
assert Float64(5.0).fdim(3) == 2
Float64.floor:
short: floor function
description: >
Rounds a number down to the nearest integer.
return:
type: 'Float64'
description: >
The largest integer less than or equal to `x`.
args:
x:
type: 'Float64'
description: >
The number to be rounded down.
example: |
assert Float64(3.7).floor() == 3
Float64.hypot:
short: Euclidean distance function
description: >
Computes the Euclidean norm, $\sqrt{x^2 + y^2}$, of two numbers.
return:
type: 'Float64'
description: >
The Euclidean norm of `x` and `y`.
args:
x:
type: 'Float64'
description: >
The first number.
y:
type: 'Float64'
description: >
The second number.
example: |
assert Float64.hypot(3, 4) == 5
Float64.isfinite:
short: check for finite number
description: >
Checks if a number is finite.
return:
type: 'Bool'
description: >
`yes` if `n` is finite, `no` otherwise.
args:
n:
type: 'Float64'
description: >
The number to be checked.
example: |
assert Float64(1.0).isfinite()
assert not Float64.INF.isfinite()
Float64.is_between:
short: check if a number is in a range
description: >
Determines if a number is between two numbers (inclusive).
return:
type: 'Bool'
description: >
`yes` if `a <= x and x <= b` or `b <= x and x <= a`, otherwise `no`
args:
x:
type: 'Float64'
description: >
The integer to be checked.
low:
type: 'Float64'
description: >
One end of the range to check (inclusive).
high:
type: 'Float64'
description: >
The other end of the range to check (inclusive).
example: |
assert Float64(7.5).is_between(1, 10)
assert Float64(7.5).is_between(10, 1)
assert not Float64(7.5).is_between(100, 200)
assert Float64(7.5).is_between(1, 7.5)
Float64.isinf:
short: check for infinite number
description: >
Checks if a number is infinite.
return:
type: 'Bool'
description: >
`yes` if `n` is infinite, `no` otherwise.
args:
n:
type: 'Float64'
description: >
The number to be checked.
example: |
assert Float64.INF.isinf()
assert not Float64(1.0).isinf()
Float64.j0:
short: Bessel function
description: >
Computes the Bessel function of the first kind of order 0.
return:
type: 'Float64'
description: >
The Bessel function of the first kind of order 0 of `x`.
args:
x:
type: 'Float64'
description: >
The number for which the Bessel function is to be calculated.
example: |
assert Float64(0.0).j0() == 1
Float64.j1:
short: Bessel function
description: >
Computes the Bessel function of the first kind of order 1.
return:
type: 'Float64'
description: >
The Bessel function of the first kind of order 1 of `x`.
args:
x:
type: 'Float64'
description: >
The number for which the Bessel function is to be calculated.
example: |
assert Float64(0.0).j1() == 0
Float64.log:
short: natural logarithm
description: >
Computes the natural logarithm (base $e$) of a number.
return:
type: 'Float64'
description: >
The natural logarithm of `x`.
args:
x:
type: 'Float64'
description: >
The number for which the natural logarithm is to be calculated.
example: |
assert Float64.E.log() == 1
Float64.log10:
short: logarithm base-10
description: >
Computes the base-10 logarithm of a number.
return:
type: 'Float64'
description: >
The base-10 logarithm of `x`.
args:
x:
type: 'Float64'
description: >
The number for which the base-10 logarithm is to be calculated.
example: |
assert Float64(100.0).log10() == 2
Float64.log1p:
short: logarithm of 1 plus x
description: >
Computes $\log(1 + x)$ for a number.
return:
type: 'Float64'
description: >
The value of $\log(1 + x)$.
args:
x:
type: 'Float64'
description: >
The number for which $\log(1 + x)$ is to be calculated.
example: |
assert Float64(1.0).log1p().near(0.6931471805599453)
Float64.log2:
short: logarithm base-2
description: >
Computes the base-2 logarithm of a number.
return:
type: 'Float64'
description: >
The base-2 logarithm of `x`.
args:
x:
type: 'Float64'
description: >
The number for which the base-2 logarithm is to be calculated.
example: |
assert Float64(8.0).log2() == 3
Float64.logb:
short: exponent of a floating point value
description: >
Computes the binary exponent (base-2 logarithm) of a number.
return:
type: 'Float64'
description: >
The binary exponent of `x`.
args:
x:
type: 'Float64'
description: >
The number for which the binary exponent is to be calculated.
example: |
assert Float64(8.0).logb() == 3
Float64.mix:
short: mix two numbers by an amount
description: >
Interpolates between two numbers based on a given amount.
return:
type: 'Float64'
description: >
The interpolated number between `x` and `y` based on `amount`.
args:
amount:
type: 'Float64'
description: >
The interpolation factor (between `0` and `1`).
x:
type: 'Float64'
description: >
The starting number.
y:
type: 'Float64'
description: >
The ending number.
example: |
assert Float64(0.5).mix(10, 20) == 15
assert Float64(0.25).mix(10, 20) == 12.5
Float64.near:
short: check if two numbers are near each other
description: >
Checks if two numbers are approximately equal within specified tolerances. If
two numbers are within an absolute difference or the ratio between the two is
small enough, they are considered near each other.
return:
type: 'Bool'
description: >
`yes` if `x` and `y` are approximately equal within the specified tolerances, `no` otherwise.
args:
x:
type: 'Float64'
description: >
The first number.
y:
type: 'Float64'
description: >
The second number.
ratio:
type: 'Float64'
default: '1e-9'
description: >
The relative tolerance. Default is `1e-9`.
min_epsilon:
type: 'Float64'
default: '1e-9'
description: >
The absolute tolerance. Default is `1e-9`.
example: |
assert Float64(1.0).near(1.000000001)
assert Float64(100.0).near(110, ratio=0.1)
assert Float64(5.0).near(5.1, min_epsilon=0.1)
Float64.nextafter:
short: next floating point number
description: >
Computes the next representable value after a given number towards a specified direction.
return:
type: 'Float64'
description: >
The next representable value after `x` in the direction of `y`.
args:
x:
type: 'Float64'
description: >
The starting number.
y:
type: 'Float64'
description: >
The direction towards which to find the next representable value.
example: |
assert Float64(1.0).nextafter(1.1) == 1.0000000000000002
Float64.parse:
short: convert text to number
description: >
Converts a text representation of a number into a floating-point number.
return:
type: 'Float64?'
description: >
The number represented by the text or `none` if the entire text can't be parsed
as a number.
args:
text:
type: 'Text'
description: >
The text containing the number.
remainder:
type: '&Text?'
default: 'none'
description: >
If non-none, this argument will be set to the remainder of the text after the matching part.
If none, parsing will only succeed if the entire text matches.
example: |
assert Float64.parse("3.14") == 3.14
assert Float64.parse("1e3") == 1000
assert Float64.parse("1.5junk") == none
remainder : Text
assert Float64.parse("1.5junk", &remainder) == 1.5
assert remainder == "junk"
Float64.percent:
short: format as a percentage
description: >
Convert a number into a percentage text with a percent sign.
return:
type: 'Text'
description: >
A text representation of the number as a percentage with a percent sign.
args:
n:
type: 'Float64'
description: >
The number to be converted to a percent.
precision:
type: 'Float64'
default: '0.01'
description: >
Round the percentage to this precision level.
example: |
assert Float64(0.5).percent() == "50%"
assert (Float64(1.) / Float64(3.)).percent(2) == "34%"
assert (Float64(1.) / Float64(3.)).percent(precision=0.0001) == "33.3333%"
assert (Float64(1.) / Float64(3.)).percent(precision=10.) == "30%"
Float64.with_precision:
short: round to a given precision
description: >
Round a number to the given precision level (specified as `10`, `.1`, `.001` etc).
return:
type: 'Float64'
description: >
The number, rounded to the given precision level.
args:
n:
type: 'Float64'
description: >
The number to be rounded to a given precision.
precision:
type: 'Float64'
description: >
The precision to which the number should be rounded.
example: |
assert Float64(0.1234567).with_precision(0.01) == 0.12
assert Float64(123456.).with_precision(100) == 123500
assert Float64(1234567.).with_precision(5) == 1234565
Float64.rint:
short: round to nearest integer
description: >
Rounds a number to the nearest integer, with ties rounded to the nearest even integer.
return:
type: 'Float64'
description: >
The nearest integer value of `x`.
args:
x:
type: 'Float64'
description: >
The number to be rounded.
example: |
assert Float64(3.5).rint() == 4
assert Float64(2.5).rint() == 2
Float64.round:
short: round to nearest integer
description: >
Rounds a number to the nearest whole number integer.
return:
type: 'Float64'
description: >
The nearest integer value of `x`.
args:
x:
type: 'Float64'
description: >
The number to be rounded.
example: |
assert Float64(2.3).round() == 2
assert Float64(2.7).round() == 3
Float64.significand:
short: get mantissa
description: >
Extracts the significand (or mantissa) of a number.
return:
type: 'Float64'
description: >
The significand of `x`.
args:
x:
type: 'Float64'
description: >
The number from which to extract the significand.
example: |
assert Float64(1234.567).significand() == 1.2056318359375
Float64.sin:
short: sine
description: >
Computes the sine of a number (angle in radians).
return:
type: 'Float64'
description: >
The sine of `x`.
args:
x:
type: 'Float64'
description: >
The angle in radians.
example: |
assert Float64(0.0).sin() == 0
Float64.sinh:
short: hyperbolic sine
description: >
Computes the hyperbolic sine of a number.
return:
type: 'Float64'
description: >
The hyperbolic sine of `x`.
args:
x:
type: 'Float64'
description: >
The number for which the hyperbolic sine is to be calculated.
example: |
assert Float64(0.0).sinh() == 0
Float64.sqrt:
short: square root
description: >
Computes the square root of a number.
return:
type: 'Float64'
description: >
The square root of `x`.
args:
x:
type: 'Float64'
description: >
The number for which the square root is to be calculated.
example: |
assert Float64(16.0).sqrt() == 4
Float64.tan:
short: tangent
description: >
Computes the tangent of a number (angle in radians).
return:
type: 'Float64'
description: >
The tangent of `x`.
args:
x:
type: 'Float64'
description: >
The angle in radians.
example: |
assert Float64(0.0).tan() == 0
Float64.tanh:
short: hyperbolic tangent
description: >
Computes the hyperbolic tangent of a number.
return:
type: 'Float64'
description: >
The hyperbolic tangent of `x`.
args:
x:
type: 'Float64'
description: >
The number for which the hyperbolic tangent is to be calculated.
example: |
assert Float64(0.0).tanh() == 0
Float64.tgamma:
short: "true gamma function"
description: >
Computes the gamma function of a number.
return:
type: 'Float64'
description: >
The gamma function of `x`.
args:
x:
type: 'Float64'
description: >
The number for which the gamma function is to be calculated.
example: |
assert Float64(1.0).tgamma() == 1
Float64.trunc:
short: truncate a number
description: >
Truncates a number to the nearest integer towards zero.
return:
type: 'Float64'
description: >
The integer part of `x` towards zero.
args:
x:
type: 'Float64'
description: >
The number to be truncated.
example: |
assert Float64(3.7).trunc() == 3
assert Float64(-3.7).trunc() == -3
Float64.y0:
short: Bessel function
description: >
Computes the Bessel function of the second kind of order 0.
return:
type: 'Float64'
description: >
The Bessel function of the second kind of order 0 of `x`.
args:
x:
type: 'Float64'
description: >
The number for which the Bessel function is to be calculated.
example: |
assert Float64(1.0).y0().near(0.08825696421567698)
Float64.y1:
short: Bessel function
description: >
Computes the Bessel function of the second kind of order 1.
return:
type: 'Float64'
description: >
The Bessel function of the second kind of order 1 of `x`.
args:
x:
type: 'Float64'
description: >
The number for which the Bessel function is to be calculated.
example: |
assert Float64(1.0).y1().near(-0.7812128213002887)
Float64.1_PI:
short: 1/pi
type: Float64
description: >
The constant $\frac{1}{\pi}$.
Float64.2_PI:
short: 2*pi
type: Float64
description: >
The constant $2 \times \pi$.
Float64.2_SQRTPI:
short: 2*sqrt(pi)
type: Float64
description: >
The constant $2 \times \sqrt{\pi}$.
Float64.E:
short: Euler's constant
type: Float64
description: >
The base of the natural logarithm ($e$).
Float64.INF:
short: infinity
type: Float64
description: >
Positive infinity.
Float64.LN10:
short: log(10)
type: Float64
description: >
The natural logarithm of 10.
Float64.LN2:
short: log(2)
type: Float64
description: >
The natural logarithm of 2.
Float64.LOG2E:
short: log_2(e)
type: Float64
description: >
The base 2 logarithm of $e$
Float64.PI:
short: pi
type: Float64
description: >
Pi ($\pi$).
Float64.PI_2:
short: pi/2
type: Float64
description: >
$\frac{\pi}{2}$
Float64.PI_4:
short: pi/4
type: Float64
description: >
$\frac{\pi}{4}$
Float64.SQRT1_2:
short: sqrt(1/2)
type: Float64
description: >
$\sqrt{\frac{1}{2}}$
Float64.SQRT2:
short: sqrt(2)
type: Float64
description: >
$\sqrt{2}$
Float64.TAU:
short: 2*pi
type: Float64
description: >
Tau ($2 \times \pi$)
|