Mathematics

    Unary minus operator.

    See also: abs, .

    Examples

    1. -1
    2. julia> -(2)
    3. -2
    4. julia> -[1 2; 3 4]
    5. 2×2 Matrix{Int64}:
    6. -1 -2
    7. -3 -4

    source

    — Function

    1. +(x, y...)

    Addition operator. x+y+z+... calls this function with all arguments, i.e. +(x, y, z, ...).

    Examples

    1. julia> 1 + 20 + 4
    2. 25
    3. julia> +(1, 20, 4)
    4. 25

    source

    1. dt::Date + t::Time -> DateTime

    The addition of a Date with a Time produces a DateTime. The hour, minute, second, and millisecond parts of the Time are used along with the year, month, and day of the Date to create the new DateTime. Non-zero microseconds or nanoseconds in the Time type will result in an InexactError being thrown.

    — Method

    1. -(x, y)

    Subtraction operator.

    Examples

    1. julia> 2 - 3
    2. -1
    3. julia> -(2, 4.5)
    4. -2.5

    source

    — Method

    1. *(x, y...)

    Multiplication operator. x*y*z*... calls this function with all arguments, i.e. *(x, y, z, ...).

    Examples

    1. julia> 2 * 7 * 8
    2. 112
    3. julia> *(2, 7, 8)
    4. 112

    source

    — Function

    1. /(x, y)

    Right division operator: multiplication of x by the inverse of y on the right. Gives floating-point results for integer arguments.

    Examples

    1. julia> 1/2
    2. 0.5
    3. julia> 4/2
    4. 2.0
    5. julia> 4.5/2
    6. 2.25

    source

    1. A / B

    Matrix right-division: A / B is equivalent to (B' \ A')' where is the left-division operator. For square matrices, the result X is such that A == X*B.

    See also: rdiv!.

    Examples

    1. julia> A = Float64[1 4 5; 3 9 2]; B = Float64[1 4 2; 3 4 2; 8 7 1];
    2. julia> X = A / B
    3. 2×3 Matrix{Float64}:
    4. -0.65 3.75 -1.2
    5. 3.25 -2.75 1.0
    6. julia> isapprox(A, X*B)
    7. true
    8. julia> isapprox(X, A*pinv(B))
    9. true

    — Method

    1. \(x, y)

    Left division operator: multiplication of y by the inverse of x on the left. Gives floating-point results for integer arguments.

    Examples

    1. julia> 3 \ 6
    2. 2.0
    3. julia> inv(3) * 6
    4. 2.0
    5. julia> A = [4 3; 2 1]; x = [5, 6];
    6. julia> A \ x
    7. 2-element Vector{Float64}:
    8. 6.5
    9. -7.0
    10. julia> inv(A) * x
    11. 2-element Vector{Float64}:
    12. 6.5
    13. -7.0

    source

    — Method

    1. ^(x, y)

    Exponentiation operator. If x is a matrix, computes matrix exponentiation.

    If y is an Int literal (e.g. 2 in x^2 or -3 in x^-3), the Julia code x^y is transformed by the compiler to Base.literal_pow(^, x, Val(y)), to enable compile-time specialization on the value of the exponent. (As a default fallback we have Base.literal_pow(^, x, Val(y)) = ^(x,y), where usually ^ == Base.^ unless ^ has been defined in the calling namespace.) If y is a negative integer literal, then Base.literal_pow transforms the operation to inv(x)^-y by default, where -y is positive.

    Examples

    1. julia> 3^5
    2. 243
    3. julia> A = [1 2; 3 4]
    4. 2×2 Matrix{Int64}:
    5. 1 2
    6. 3 4
    7. julia> A^3
    8. 2×2 Matrix{Int64}:
    9. 37 54
    10. 81 118

    source

    — Function

    1. fma(x, y, z)

    Computes x*y+z without rounding the intermediate result x*y. On some systems this is significantly more expensive than x*y+z. fma is used to improve accuracy in certain algorithms. See muladd.

    Base.muladd — Function

    1. muladd(A, y, z)

    Combined multiply-add, A*y .+ z, for matrix-matrix or matrix-vector multiplication. The result is always the same size as A*y, but z may be smaller, or a scalar.

    Julia 1.6

    These methods require Julia 1.6 or later.

    Examples

    1. julia> A=[1.0 2.0; 3.0 4.0]; B=[1.0 1.0; 1.0 1.0]; z=[0, 100];
    2. julia> muladd(A, B, z)
    3. 2×2 Matrix{Float64}:
    4. 3.0 3.0
    5. 107.0 107.0
    1. muladd(x, y, z)

    Combined multiply-add: computes x*y+z, but allowing the add and multiply to be merged with each other or with surrounding operations for performance. For example, this may be implemented as an if the hardware supports it efficiently. The result can be different on different machines and can also be different on the same machine due to constant propagation or other optimizations. See fma.

    Examples

    1. julia> muladd(3, 2, 1)
    2. 7
    3. julia> 3 * 2 + 1
    4. 7

    Base.inv — Method

    1. inv(x)

    Return the multiplicative inverse of x, such that x*inv(x) or inv(x)*x yields (the multiplicative identity) up to roundoff errors.

    If x is a number, this is essentially the same as one(x)/x, but for some types inv(x) may be slightly more efficient.

    Examples

    1. julia> inv(2)
    2. 0.5
    3. julia> inv(1 + 2im)
    4. 0.2 - 0.4im
    5. julia> inv(1 + 2im) * (1 + 2im)
    6. 1.0 + 0.0im
    7. julia> inv(2//3)
    8. 3//2

    Julia 1.2

    inv(::Missing) requires at least Julia 1.2.

    source

    — Function

    1. div(x, y)
    2. ÷(x, y)

    The quotient from Euclidean (integer) division. Generally equivalent to a mathematical operation x/y without a fractional part.

    See also: cld, , rem, .

    Examples

    1. julia> 9 ÷ 4
    2. 2
    3. julia> -5 ÷ 3
    4. -1
    5. julia> 5.0 ÷ 2
    6. 2.0
    7. julia> div.(-5:5, 3)'
    8. 1×11 adjoint(::Vector{Int64}) with eltype Int64:
    9. -1 -1 -1 0 0 0 0 0 1 1 1

    source

    — Function

    1. fld(x, y)

    Largest integer less than or equal to x/y. Equivalent to div(x, y, RoundDown).

    See also div, , fld1.

    Examples

    1. julia> fld(7.3,5.5)
    2. 1.0
    3. julia> fld.(-5:5, 3)'
    4. 1×11 adjoint(::Vector{Int64}) with eltype Int64:
    5. -2 -2 -1 -1 -1 0 0 0 1 1 1

    Because fld(x, y) implements strictly correct floored rounding based on the true value of floating-point numbers, unintuitive situations can arise. For example:

    1. julia> fld(6.0,0.1)
    2. 59.0
    3. julia> 6.0/0.1
    4. 60.0
    5. julia> 6.0/big(0.1)
    6. 59.99999999999999666933092612453056361837965690217069245739573412231113406246995

    What is happening here is that the true value of the floating-point number written as 0.1 is slightly larger than the numerical value 1/10 while 6.0 represents the number 6 precisely. Therefore the true value of 6.0 / 0.1 is slightly less than 60. When doing division, this is rounded to precisely 60.0, but fld(6.0, 0.1) always takes the floor of the true value, so the result is 59.0.

    Base.cld — Function

    1. cld(x, y)

    Smallest integer larger than or equal to x/y. Equivalent to div(x, y, RoundUp).

    See also , fld.

    Examples

    1. julia> cld(5.5,2.2)
    2. 3.0
    3. julia> cld.(-5:5, 3)'
    4. 1×11 adjoint(::Vector{Int64}) with eltype Int64:
    5. -1 -1 -1 0 0 0 1 1 1 2 2

    Base.mod — Function

    1. mod(x::Integer, r::AbstractUnitRange)

    Find y in the range r such that $x ≡ y (mod n)$, where n = length(r), i.e. y = mod(x - first(r), n) + first(r).

    See also .

    Examples

    1. julia> mod(0, Base.OneTo(3)) # mod1(0, 3)
    2. 3
    3. julia> mod(3, 0:2) # mod(3, 3)
    4. 0

    Julia 1.3

    This method requires at least Julia 1.3.

    source

    1. mod(x, y)
    2. rem(x, y, RoundDown)

    The reduction of x modulo y, or equivalently, the remainder of x after floored division by y, i.e. x - y*fld(x,y) if computed without intermediate rounding.

    The result will have the same sign as y, and magnitude less than abs(y) (with some exceptions, see note below).

    Note

    When used with floating point values, the exact result may not be representable by the type, and so rounding error may occur. In particular, if the exact result is very close to y, then it may be rounded to y.

    See also: , div, , mod1, .

    1. julia> mod(8, 3)
    2. 2
    3. julia> mod(9, 3)
    4. 0
    5. julia> mod(8.9, 3)
    6. 2.9000000000000004
    7. julia> mod(eps(), 3)
    8. 2.220446049250313e-16
    9. julia> mod(-eps(), 3)
    10. 3.0
    11. julia> mod.(-5:5, 3)'
    12. 1×11 adjoint(::Vector{Int64}) with eltype Int64:
    13. 1 2 0 1 2 0 1 2 0 1 2

    source

    1. rem(x::Integer, T::Type{<:Integer}) -> T
    2. mod(x::Integer, T::Type{<:Integer}) -> T
    3. %(x::Integer, T::Type{<:Integer}) -> T

    Find y::T such that xy (mod n), where n is the number of integers representable in T, and y is an integer in [typemin(T),typemax(T)]. If T can represent any integer (e.g. T == BigInt), then this operation corresponds to a conversion to T.

    Examples

    1. julia> 129 % Int8
    2. -127

    Base.rem — Function

    1. rem(x, y)
    2. %(x, y)

    Remainder from Euclidean division, returning a value of the same sign as x, and smaller in magnitude than y. This value is always exact.

    See also: , mod, , divrem.

    Examples

    1. julia> x = 15; y = 4;
    2. julia> x % y
    3. 3
    4. julia> x == div(x, y) * y + rem(x, y)
    5. true
    6. julia> rem.(-5:5, 3)'
    7. 1×11 adjoint(::Vector{Int64}) with eltype Int64:
    8. -2 -1 0 -2 -1 0 1 2 0 1 2

    Base.Math.rem2pi — Function

    1. rem2pi(x, r::RoundingMode)

    Compute the remainder of x after integer division by , with the quotient rounded according to the rounding mode r. In other words, the quantity

    1. x - 2π*round(x/(2π),r)

    without any intermediate rounding. This internally uses a high precision approximation of 2π, and so will give a more accurate result than rem(x,2π,r)

    • if r == RoundNearest, then the result is in the interval $[-π, π]$. This will generally be the most accurate result. See also .

    • if r == RoundToZero, then the result is in the interval $[0, 2π]$ if x is positive,. or $[-2π, 0]$ otherwise. See also RoundToZero.

    • if r == RoundDown, then the result is in the interval $[0, 2π]$. See also .

    • if r == RoundUp, then the result is in the interval $[-2π, 0]$. See also RoundUp.

    Examples

    1. julia> rem2pi(7pi/4, RoundNearest)
    2. -0.7853981633974485
    3. julia> rem2pi(7pi/4, RoundDown)
    4. 5.497787143782138

    Base.Math.mod2pi — Function

    1. mod2pi(x)

    Modulus after division by , returning in the range $[0,2π)$.

    This function computes a floating point representation of the modulus after division by numerically exact , and is therefore not exactly the same as mod(x,2π), which would compute the modulus of x relative to division by the floating-point number .

    Note

    Depending on the format of the input value, the closest representable value to 2π may be less than 2π. For example, the expression mod2pi(2π) will not return 0, because the intermediate value of 2*π is a Float64 and 2*Float64(π) < 2*big(π). See for more refined control of this behavior.

    Examples

    1. julia> mod2pi(9*pi/4)
    2. 0.7853981633974481

    source

    — Function

    1. divrem(x, y, r::RoundingMode=RoundToZero)

    The quotient and remainder from Euclidean division. Equivalent to (div(x,y,r), rem(x,y,r)). Equivalently, with the default value of r, this call is equivalent to (x÷y, x%y).

    See also: fldmod, .

    Examples

    1. julia> divrem(3,7)
    2. (0, 3)
    3. julia> divrem(7,3)
    4. (2, 1)

    source

    — Function

    1. fldmod(x, y)

    The floored quotient and modulus after division. A convenience wrapper for divrem(x, y, RoundDown). Equivalent to (fld(x,y), mod(x,y)).

    See also: fld, , fldmod1.

    Base.fld1 — Function

    1. fld1(x, y)

    Flooring division, returning a value consistent with mod1(x,y)

    See also , fldmod1.

    Examples

    1. julia> x = 15; y = 4;
    2. julia> fld1(x, y)
    3. 4
    4. julia> x == fld(x, y) * y + mod(x, y)
    5. true
    6. julia> x == (fld1(x, y) - 1) * y + mod1(x, y)
    7. true

    Base.mod1 — Function

    1. mod1(x, y)

    Modulus after flooring division, returning a value r such that mod(r, y) == mod(x, y) in the range $(0, y]$ for positive y and in the range $[y,0)$ for negative y.

    With integer arguments and positive y, this is equal to mod(x, 1:y), and hence natural for 1-based indexing. By comparison, mod(x, y) == mod(x, 0:y-1) is natural for computations with offsets or strides.

    See also , fld1, .

    Examples

    1. julia> mod1(4, 2)
    2. 2
    3. julia> mod1.(-5:5, 3)'
    4. 1×11 adjoint(::Vector{Int64}) with eltype Int64:
    5. 1 2 3 1 2 3 1 2 3 1 2
    6. julia> mod1.([-0.1, 0, 0.1, 1, 2, 2.9, 3, 3.1]', 3)
    7. 1×8 Matrix{Float64}:
    8. 2.9 3.0 0.1 1.0 2.0 2.9 3.0 0.1

    source

    — Function

    1. fldmod1(x, y)

    Return (fld1(x,y), mod1(x,y)).

    See also fld1, .

    source

    — Function

    1. //(num, den)

    Divide two integers or rational numbers, giving a Rational result.

    Examples

    1. julia> 3 // 5
    2. 3//5
    3. julia> (3 // 5) // (2 // 1)
    4. 3//10

    Base.rationalize — Function

    1. rationalize([T<:Integer=Int,] x; tol::Real=eps(x))

    Approximate floating point number x as a number with components of the given integer type. The result will differ from x by no more than tol.

    Examples

    1. julia> rationalize(5.6)
    2. 28//5
    3. julia> a = rationalize(BigInt, 10.3)
    4. 103//10
    5. julia> typeof(numerator(a))
    6. BigInt

    source

    — Function

    1. numerator(x)

    Numerator of the rational representation of x.

    Examples

    1. julia> numerator(2//3)
    2. 2
    3. julia> numerator(4)
    4. 4

    source

    — Function

    1. denominator(x)

    Denominator of the rational representation of x.

    Examples

    1. julia> denominator(2//3)
    2. 3
    3. julia> denominator(4)
    4. 1

    source

    — Function

    1. <<(x, n)

    Left bit shift operator, x << n. For n >= 0, the result is x shifted left by n bits, filling with 0s. This is equivalent to x * 2^n. For n < 0, this is equivalent to x >> -n.

    Examples

    1. julia> Int8(3) << 2
    2. 12
    3. julia> bitstring(Int8(3))
    4. "00000011"
    5. julia> bitstring(Int8(12))
    6. "00001100"

    See also >>, , exp2, .

    source

    1. <<(B::BitVector, n) -> BitVector

    Left bit shift operator, B << n. For n >= 0, the result is B with elements shifted n positions backwards, filling with false values. If n < 0, elements are shifted forwards. Equivalent to B >> -n.

    Examples

    1. julia> B = BitVector([true, false, true, false, false])
    2. 5-element BitVector:
    3. 1
    4. 0
    5. 1
    6. 0
    7. 0
    8. julia> B << 1
    9. 5-element BitVector:
    10. 0
    11. 1
    12. 0
    13. 0
    14. 0
    15. julia> B << -1
    16. 5-element BitVector:
    17. 0
    18. 1
    19. 0
    20. 1
    21. 0

    Base.:>> — Function

    1. >>(x, n)

    Right bit shift operator, x >> n. For n >= 0, the result is x shifted right by n bits, where n >= 0, filling with 0s if x >= 0, 1s if x < 0, preserving the sign of x. This is equivalent to fld(x, 2^n). For n < 0, this is equivalent to x << -n.

    Examples

    1. julia> Int8(13) >> 2
    2. 3
    3. julia> bitstring(Int8(13))
    4. "00001101"
    5. julia> bitstring(Int8(3))
    6. "00000011"
    7. julia> Int8(-14) >> 2
    8. -4
    9. julia> bitstring(Int8(-14))
    10. "11110010"
    11. julia> bitstring(Int8(-4))
    12. "11111100"

    See also , <<.

    1. >>(B::BitVector, n) -> BitVector

    Right bit shift operator, B >> n. For n >= 0, the result is B with elements shifted n positions forward, filling with false values. If n < 0, elements are shifted backwards. Equivalent to B << -n.

    Examples

    1. julia> B = BitVector([true, false, true, false, false])
    2. 5-element BitVector:
    3. 1
    4. 0
    5. 1
    6. 0
    7. 0
    8. julia> B >> 1
    9. 5-element BitVector:
    10. 0
    11. 1
    12. 0
    13. 1
    14. 0
    15. julia> B >> -1
    16. 5-element BitVector:
    17. 0
    18. 1
    19. 0
    20. 0
    21. 0

    source

    — Function

    1. >>>(x, n)

    Unsigned right bit shift operator, x >>> n. For n >= 0, the result is x shifted right by n bits, where n >= 0, filling with 0s. For n < 0, this is equivalent to x << -n.

    For Unsigned integer types, this is equivalent to . For Signed integer types, this is equivalent to signed(unsigned(x) >> n).

    Examples

    1. julia> Int8(-14) >>> 2
    2. 60
    3. julia> bitstring(Int8(-14))
    4. "11110010"
    5. julia> bitstring(Int8(60))
    6. "00111100"

    s are treated as if having infinite size, so no filling is required and this is equivalent to >>.

    See also , <<.

    1. >>>(B::BitVector, n) -> BitVector

    Unsigned right bitshift operator, B >>> n. Equivalent to B >> n. See >> for details and examples.

    Base.bitrotate — Function

    1. bitrotate(x::Base.BitInteger, k::Integer)

    bitrotate(x, k) implements bitwise rotation. It returns the value of x with its bits rotated left k times. A negative value of k will rotate to the right instead.

    Julia 1.5

    This function requires Julia 1.5 or later.

    See also: , circshift, .

    1. julia> bitrotate(UInt8(114), 2)
    2. 0xc9
    3. julia> bitstring(bitrotate(0b01110010, 2))
    4. "11001001"
    5. julia> bitstring(bitrotate(0b01110010, -2))
    6. "10011100"
    7. julia> bitstring(bitrotate(0b01110010, 8))
    8. "01110010"

    source

    — Function

    1. (:)(start::CartesianIndex, [step::CartesianIndex], stop::CartesianIndex)

    Construct CartesianIndices from two CartesianIndex and an optional step.

    Julia 1.1

    This method requires at least Julia 1.1.

    Julia 1.6

    The step range method start:step:stop requires at least Julia 1.6.

    Examples

    1. julia> I = CartesianIndex(2,1);
    2. julia> J = CartesianIndex(3,3);
    3. julia> I:J
    4. CartesianIndices((2:3, 1:3))
    5. julia> I:CartesianIndex(1, 2):J
    6. CartesianIndices((2:1:3, 1:2:3))

    1. (:)(start, [step], stop)

    Range operator. a:b constructs a range from a to b with a step size of 1 (a UnitRange) , and a:s:b is similar but uses a step size of s (a ).

    : is also used in indexing to select whole dimensions and for Symbol literals, as in e.g. :hello.

    Base.range — Function

    1. range(start, stop, length)
    2. range(start, stop; length, step)
    3. range(start; length, stop, step)
    4. range(;start, length, stop, step)

    Construct a specialized array with evenly spaced elements and optimized storage (an ) from the arguments. Mathematically a range is uniquely determined by any three of start, step, stop and length. Valid invocations of range are:

    • Call range with any three of start, step, stop, length.
    • Call range with two of start, stop, length. In this case step will be assumed to be one. If both arguments are Integers, a UnitRange will be returned.
    • Call range with one of stop or length. start and step will be assumed to be one.

    See Extended Help for additional details on the returned type.

    Examples

    1. julia> range(1, length=100)
    2. 1:100
    3. julia> range(1, stop=100)
    4. 1:100
    5. julia> range(1, step=5, length=100)
    6. 1:5:496
    7. julia> range(1, step=5, stop=100)
    8. 1:5:96
    9. julia> range(1, 10, length=101)
    10. 1.0:0.09:10.0
    11. julia> range(1, 100, step=5)
    12. 1:5:96
    13. julia> range(stop=10, length=5)
    14. 6:10
    15. julia> range(stop=10, step=1, length=5)
    16. 6:1:10
    17. julia> range(start=1, step=1, stop=10)
    18. 1:1:10
    19. julia> range(; length = 10)
    20. Base.OneTo(10)
    21. julia> range(; stop = 6)
    22. Base.OneTo(6)
    23. julia> range(; stop = 6.5)
    24. 1.0:1.0:6.0

    If length is not specified and stop - start is not an integer multiple of step, a range that ends before stop will be produced.

    1. julia> range(1, 3.5, step=2)
    2. 1.0:2.0:3.0

    Special care is taken to ensure intermediate values are computed rationally. To avoid this induced overhead, see the constructor.

    Julia 1.1

    stop as a positional argument requires at least Julia 1.1.

    Julia 1.7

    The versions without keyword arguments and start as a keyword argument require at least Julia 1.7.

    Julia 1.8

    The versions with stop as a sole keyword argument, or length as a sole keyword argument require at least Julia 1.8.

    Extended Help

    range will produce a Base.OneTo when the arguments are Integers and

    • Only length is provided
    • Only stop is provided

    range will produce a UnitRange when the arguments are Integers and

    • Only start and stop are provided
    • Only length and stop are provided

    A UnitRange is not produced if step is provided even if specified as one.

    source

    — Type

    1. Base.OneTo(n)

    Define an AbstractUnitRange that behaves like 1:n, with the added distinction that the lower limit is guaranteed (by the type system) to be 1.

    source

    — Type

    1. StepRangeLen( ref::R, step::S, len, [offset=1]) where { R,S}
    2. StepRangeLen{T,R,S}( ref::R, step::S, len, [offset=1]) where {T,R,S}
    3. StepRangeLen{T,R,S,L}(ref::R, step::S, len, [offset=1]) where {T,R,S,L}

    A range r where r[i] produces values of type T (in the first form, T is deduced automatically), parameterized by a reference value, a step, and the length. By default ref is the starting value r[1], but alternatively you can supply it as the value of r[offset] for some other index 1 <= offset <= len. In conjunction with TwicePrecision this can be used to implement ranges that are free of roundoff error.

    source

    — Function

    1. ==(x, y)

    Generic equality operator. Falls back to \===. Should be implemented for all types with a notion of equality, based on the abstract value that an instance represents. For example, all numeric types are compared by numeric value, ignoring type. Strings are compared as sequences of characters, ignoring encoding. For collections, == is generally called recursively on all contents, though other properties (like the shape for arrays) may also be taken into account.

    This operator follows IEEE semantics for floating-point numbers: 0.0 == -0.0 and NaN != NaN.

    The result is of type Bool, except when one of the operands is , in which case missing is returned (three-valued logic). For collections, missing is returned if at least one of the operands contains a missing value and all non-missing values are equal. Use or \=== to always get a Bool result.

    Implementation

    New numeric types should implement this function for two arguments of the new type, and handle comparison to other types via promotion rules where possible.

    falls back to ==, so new methods of == will be used by the Dict type to compare keys. If your type will be used as a dictionary key, it should therefore also implement .

    If some type defines ==, isequal, and then it should also implement < to ensure consistency of comparisons.

    Base.:!= — Function

    1. !=(x, y)
    2. ≠(x,y)

    Not-equals comparison operator. Always gives the opposite answer as .

    Implementation

    New types should generally not implement this, and rely on the fallback definition !=(x,y) = !(x==y) instead.

    Examples

    1. julia> 3 != 2
    2. true
    3. false

    source

    1. !=(x)

    Create a function that compares its argument to x using , i.e. a function equivalent to y -> y != x. The returned function is of type Base.Fix2{typeof(!=)}, which can be used to implement specialized methods.

    Julia 1.2

    This functionality requires at least Julia 1.2.

    source

    — Function

    1. !==(x, y)
    2. ≢(x,y)

    Always gives the opposite answer as \===.

    Examples

    1. julia> a = [1, 2]; b = [1, 2];
    2. julia> a b
    3. true
    4. julia> a a
    5. false

    Base.:< — Function

      Less-than comparison operator. Falls back to . Because of the behavior of floating-point NaN values, this operator implements a partial order.

      Implementation

      New numeric types with a canonical partial order should implement this function for two arguments of the new type. Types with a canonical total order should implement isless instead.

      Examples

      1. julia> 'a' < 'b'
      2. true
      3. julia> "abc" < "abd"
      4. true
      5. julia> 5 < 3
      6. false

      1. <(x)

      Create a function that compares its argument to x using <, i.e. a function equivalent to y -> y < x. The returned function is of type Base.Fix2{typeof(<)}, which can be used to implement specialized methods.

      Julia 1.2

      This functionality requires at least Julia 1.2.

      Base.:<= — Function

      1. <=(x, y)
      2. ≤(x,y)

      Less-than-or-equals comparison operator. Falls back to (x < y) | (x == y).

      Examples

      1. julia> 'a' <= 'b'
      2. true
      3. julia> 7 7 9
      4. true
      5. julia> "abc" "abc"
      6. true
      7. julia> 5 <= 3
      8. false

      1. <=(x)

      Create a function that compares its argument to x using <=, i.e. a function equivalent to y -> y <= x. The returned function is of type Base.Fix2{typeof(<=)}, which can be used to implement specialized methods.

      Julia 1.2

      This functionality requires at least Julia 1.2.

      Base.:> — Function

      1. >(x, y)

      Greater-than comparison operator. Falls back to y < x.

      Implementation

      Generally, new types should implement instead of this function, and rely on the fallback definition >(x, y) = y < x.

      Examples

      1. julia> 'a' > 'b'
      2. false
      3. julia> 7 > 3 > 1
      4. true
      5. julia> "abc" > "abd"
      6. false
      7. julia> 5 > 3
      8. true

      source

      1. >(x)

      Create a function that compares its argument to x using , i.e. a function equivalent to y -> y > x. The returned function is of type Base.Fix2{typeof(>)}, which can be used to implement specialized methods.

      Julia 1.2

      This functionality requires at least Julia 1.2.

      source

      — Function

      1. >=(x, y)
      2. ≥(x,y)

      Greater-than-or-equals comparison operator. Falls back to y <= x.

      Examples

      1. julia> 'a' >= 'b'
      2. false
      3. julia> 7 7 3
      4. true
      5. julia> "abc" "abc"
      6. true
      7. julia> 5 >= 3
      8. true

      source

      1. >=(x)

      Create a function that compares its argument to x using , i.e. a function equivalent to y -> y >= x. The returned function is of type Base.Fix2{typeof(>=)}, which can be used to implement specialized methods.

      Julia 1.2

      This functionality requires at least Julia 1.2.

      source

      — Function

      1. cmp(x,y)

      Return -1, 0, or 1 depending on whether x is less than, equal to, or greater than y, respectively. Uses the total order implemented by isless.

      Examples

      1. julia> cmp(1, 2)
      2. -1
      3. julia> cmp(2, 1)
      4. 1
      5. julia> cmp(2+im, 3-im)
      6. ERROR: MethodError: no method matching isless(::Complex{Int64}, ::Complex{Int64})
      7. [...]

      source

      1. cmp(<, x, y)

      Return -1, 0, or 1 depending on whether x is less than, equal to, or greater than y, respectively. The first argument specifies a less-than comparison function to use.

      1. cmp(a::AbstractString, b::AbstractString) -> Int

      Compare two strings. Return 0 if both strings have the same length and the character at each index is the same in both strings. Return -1 if a is a prefix of b, or if a comes before b in alphabetical order. Return 1 if b is a prefix of a, or if b comes before a in alphabetical order (technically, lexicographical order by Unicode code points).

      Examples

      1. julia> cmp("abc", "abc")
      2. 0
      3. julia> cmp("ab", "abc")
      4. -1
      5. julia> cmp("abc", "ab")
      6. 1
      7. julia> cmp("ab", "ac")
      8. -1
      9. julia> cmp("ac", "ab")
      10. 1
      11. julia> cmp("α", "a")
      12. 1
      13. julia> cmp("b", "β")
      14. -1

      source

      — Function

      1. ~(x)

      Bitwise not.

      See also: !, , |.

      Examples

      1. julia> ~4
      2. -5
      3. julia> ~10
      4. -11
      5. julia> ~true
      6. false

      Base.:& — Function

      1. x & y

      Bitwise and. Implements , returning missing if one operand is missing and the other is true. Add parentheses for function application form: (&)(x, y).

      See also: , xor, .

      Examples

      source

      — Function

      1. x | y

      Bitwise or. Implements three-valued logic, returning if one operand is missing and the other is false.

      See also: &, , ||.

      Examples

      1. julia> 4 | 10
      2. 14
      3. julia> 4 | 1
      4. 5
      5. julia> true | missing
      6. true
      7. julia> false | missing
      8. missing

      Base.xor — Function

      1. xor(x, y)
      2. ⊻(x, y)

      Bitwise exclusive or of x and y. Implements , returning missing if one of the arguments is missing.

      The infix operation a ⊻ b is a synonym for xor(a,b), and can be typed by tab-completing \xor or \veebar in the Julia REPL.

      Examples

      1. julia> xor(true, false)
      2. true
      3. julia> xor(true, true)
      4. false
      5. julia> xor(true, missing)
      6. missing
      7. julia> false false
      8. false
      9. julia> [true; true; false] .⊻ [true; false; false]
      10. 3-element BitVector:
      11. 0
      12. 1
      13. 0

      Base.nand — Function

      1. nand(x, y)
      2. ⊼(x, y)

      Bitwise nand (not and) of x and y. Implements , returning missing if one of the arguments is missing.

      The infix operation a ⊼ b is a synonym for nand(a,b), and can be typed by tab-completing \nand or \barwedge in the Julia REPL.

      Examples

      1. julia> nand(true, false)
      2. true
      3. julia> nand(true, true)
      4. false
      5. julia> nand(true, missing)
      6. missing
      7. julia> false false
      8. true
      9. julia> [true; true; false] .⊼ [true; false; false]
      10. 3-element BitVector:
      11. 0
      12. 1
      13. 1

      Base.nor — Function

      1. nor(x, y)
      2. ⊽(x, y)

      The infix operation a ⊽ b is a synonym for nor(a,b), and can be typed by tab-completing \nor or \barvee in the Julia REPL.

      Examples

      1. julia> nor(true, false)
      2. false
      3. julia> nor(true, true)
      4. false
      5. julia> nor(true, missing)
      6. false
      7. julia> false false
      8. true
      9. julia> [true; true; false] .⊽ [true; false; false]
      10. 3-element BitVector:
      11. 0
      12. 0
      13. 1

      Base.:! — Function

      1. !(x)

      Boolean not. Implements , returning missing if x is missing.

      See also for bitwise not.

      Examples

      1. julia> !true
      2. false
      3. julia> !false
      4. true
      5. julia> !missing
      6. missing
      7. julia> .![true false true]
      8. 1×3 BitMatrix:
      9. 0 1 0

      source

      1. !f::Function

      Predicate function negation: when the argument of ! is a function, it returns a function which computes the boolean negation of f.

      See also .

      Examples

      1. julia> str = "∀ ε > 0, ∃ δ > 0: |x-y| < δ ⇒ |f(x)-f(y)| < ε"
      2. "∀ ε > 0, ∃ δ > 0: |x-y| < δ ⇒ |f(x)-f(y)| < ε"
      3. julia> filter(isletter, str)
      4. "εδxyδfxfyε"
      5. julia> filter(!isletter, str)
      6. "∀ > 0, ∃ > 0: |-| < ⇒ |()-()| < "

      source

      — Keyword

      1. x && y

      Short-circuiting boolean AND.

      See also &, the ternary operator ? :, and the manual section on .

      Examples

      1. julia> x = 3;
      2. julia> x > 1 && x < 10 && x isa Int
      3. true
      4. julia> x < 0 && error("expected positive x")
      5. false

      source

      — Keyword

      1. x || y

      Short-circuiting boolean OR.

      See also: |, , &&.

      Examples

      1. julia> pi < 3 || < 3
      2. true
      3. julia> false || true || println("neither is true!")
      4. true

      — Function

      1. isapprox(x, y; atol::Real=0, rtol::Real=atol>0 ? 0 : eps, nans::Bool=false[, norm::Function])

      Inexact equality comparison. Two numbers compare equal if their relative distance or their absolute distance is within tolerance bounds: isapprox returns true if norm(x-y) <= max(atol, rtol*max(norm(x), norm(y))). The default atol is zero and the default rtol depends on the types of x and y. The keyword argument nans determines whether or not NaN values are considered equal (defaults to false).

      For real or complex floating-point values, if an atol > 0 is not specified, rtol defaults to the square root of eps of the type of x or y, whichever is bigger (least precise). This corresponds to requiring equality of about half of the significant digits. Otherwise, e.g. for integer arguments or if an atol > 0 is supplied, rtol defaults to zero.

      The norm keyword defaults to abs for numeric (x,y) and to LinearAlgebra.norm for arrays (where an alternative norm choice is sometimes useful). When x and y are arrays, if norm(x-y) is not finite (i.e. ±Inf or NaN), the comparison falls back to checking whether all elements of x and y are approximately equal component-wise.

      The binary operator is equivalent to isapprox with the default arguments, and x ≉ y is equivalent to !isapprox(x,y).

      Note that x ≈ 0 (i.e., comparing to zero with the default tolerances) is equivalent to x == 0 since the default atol is 0. In such cases, you should either supply an appropriate atol (or use norm(x) ≤ atol) or rearrange your code (e.g. use x ≈ y rather than x - y ≈ 0). It is not possible to pick a nonzero atol automatically because it depends on the overall scaling (the “units”) of your problem: for example, in x - y ≈ 0, atol=1e-9 is an absurdly small tolerance if x is the in meters, but an absurdly large tolerance if x is the radius of a Hydrogen atom in meters.

      Julia 1.6

      Passing the norm keyword argument when comparing numeric (non-array) arguments requires Julia 1.6 or later.

      Examples

      1. julia> isapprox(0.1, 0.15; atol=0.05)
      2. true
      3. julia> isapprox(0.1, 0.15; rtol=0.34)
      4. true
      5. julia> isapprox(0.1, 0.15; rtol=0.33)
      6. false
      7. julia> 0.1 + 1e-10 0.1
      8. true
      9. julia> 1e-10 0
      10. false
      11. julia> isapprox(1e-10, 0, atol=1e-8)
      12. true
      13. julia> isapprox([10.0^9, 1.0], [10.0^9, 2.0]) # using `norm`
      14. true

      1. isapprox(x; kwargs...) / ≈(x; kwargs...)

      Create a function that compares its argument to x using , i.e. a function equivalent to y -> y ≈ x.

      The keyword arguments supported here are the same as those in the 2-argument isapprox.

      Julia 1.5

      This method requires Julia 1.5 or later.

      source

      — Method

      1. sin(x)

      Compute sine of x, where x is in radians.

      See also [sind], [sinpi], [sincos], [cis].

      source

      — Method

      1. cos(x)

      Compute cosine of x, where x is in radians.

      See also [cosd], [cospi], [sincos], [cis].

      source

      — Method

      1. sincos(x)

      Simultaneously compute the sine and cosine of x, where x is in radians, returning a tuple (sine, cosine).

      See also cis, , sincosd.

      Base.tan — Method

      1. tan(x)

      Compute tangent of x, where x is in radians.

      Base.Math.sind — Function

      1. sind(x)

      Compute sine of x, where x is in degrees. If x is a matrix, x needs to be a square matrix.

      Julia 1.7

      Matrix arguments require Julia 1.7 or later.

      Base.Math.cosd — Function

      1. cosd(x)

      Compute cosine of x, where x is in degrees. If x is a matrix, x needs to be a square matrix.

      Julia 1.7

      Matrix arguments require Julia 1.7 or later.

      Base.Math.tand — Function

      1. tand(x)

      Compute tangent of x, where x is in degrees. If x is a matrix, x needs to be a square matrix.

      Julia 1.7

      Matrix arguments require Julia 1.7 or later.

      Base.Math.sincosd — Function

      1. sincosd(x)

      Simultaneously compute the sine and cosine of x, where x is in degrees.

      Julia 1.3

      This function requires at least Julia 1.3.

      Base.Math.sinpi — Function

      1. sinpi(x)

      Compute $\sin(\pi x)$ more accurately than sin(pi*x), especially for large x.

      See also , cospi, .

      source

      — Function

      1. cospi(x)

      Compute $\cos(\pi x)$ more accurately than cos(pi*x), especially for large x.

      source

      — Function

      1. sincospi(x)

      Simultaneously compute sinpi(x) and (the sine and cosine of π*x, where x is in radians), returning a tuple (sine, cosine).

      Julia 1.6

      This function requires Julia 1.6 or later.

      See also: cispi, , sinpi.

      Base.sinh — Method

      1. sinh(x)

      Compute hyperbolic sine of x.

      Base.cosh — Method

      1. cosh(x)

      Compute hyperbolic cosine of x.

      Base.tanh — Method

      1. tanh(x)

      Compute hyperbolic tangent of x.

      Base.asin — Method

      1. asin(x)

      Compute the inverse sine of x, where the output is in radians.

      Base.acos — Method

      1. acos(x)

      Compute the inverse cosine of x, where the output is in radians

      Base.atan — Method

      1. atan(y)
      2. atan(y, x)

      Compute the inverse tangent of y or y/x, respectively.

      For one argument, this is the angle in radians between the positive x-axis and the point (1, y), returning a value in the interval $[-\pi/2, \pi/2]$.

      For two arguments, this is the angle in radians between the positive x-axis and the point (x, y), returning a value in the interval $[-\pi, \pi]$. This corresponds to a standard function. Note that by convention atan(0.0,x) is defined as $\pi$ and atan(-0.0,x) is defined as $-\pi$ when x < 0.

      source

      — Function

      1. asind(x)

      Compute the inverse sine of x, where the output is in degrees. If x is a matrix, x needs to be a square matrix.

      Julia 1.7

      Matrix arguments require Julia 1.7 or later.

      source

      — Function

      1. acosd(x)

      Compute the inverse cosine of x, where the output is in degrees. If x is a matrix, x needs to be a square matrix.

      Julia 1.7

      Matrix arguments require Julia 1.7 or later.

      source

      — Function

      1. atand(y)
      2. atand(y,x)

      Compute the inverse tangent of y or y/x, respectively, where the output is in degrees.

      Julia 1.7

      The one-argument method supports square matrix arguments as of Julia 1.7.

      source

      — Method

      1. sec(x)

      Compute the secant of x, where x is in radians.

      source

      — Method

      1. csc(x)

      Compute the cosecant of x, where x is in radians.

      source

      — Method

      1. cot(x)

      Compute the cotangent of x, where x is in radians.

      source

      — Function

      1. secd(x)

      Compute the secant of x, where x is in degrees.

      source

      — Function

      1. cscd(x)

      Compute the cosecant of x, where x is in degrees.

      source

      — Function

      1. cotd(x)

      Compute the cotangent of x, where x is in degrees.

      source

      — Method

      1. asec(x)

      Compute the inverse secant of x, where the output is in radians.

      source

      — Method

      1. acsc(x)

      Compute the inverse cosecant of x, where the output is in radians.

      source

      — Method

      1. acot(x)

      Compute the inverse cotangent of x, where the output is in radians.

      source

      — Function

      1. asecd(x)

      Compute the inverse secant of x, where the output is in degrees. If x is a matrix, x needs to be a square matrix.

      Julia 1.7

      Matrix arguments require Julia 1.7 or later.

      source

      — Function

      1. acscd(x)

      Compute the inverse cosecant of x, where the output is in degrees. If x is a matrix, x needs to be a square matrix.

      Julia 1.7

      Matrix arguments require Julia 1.7 or later.

      source

      — Function

      1. acotd(x)

      Compute the inverse cotangent of x, where the output is in degrees. If x is a matrix, x needs to be a square matrix.

      Julia 1.7

      Matrix arguments require Julia 1.7 or later.

      source

      — Method

      1. sech(x)

      Compute the hyperbolic secant of x.

      source

      — Method

      1. csch(x)

      Compute the hyperbolic cosecant of x.

      source

      — Method

      1. coth(x)

      Compute the hyperbolic cotangent of x.

      source

      — Method

      1. asinh(x)

      Compute the inverse hyperbolic sine of x.

      source

      — Method

      1. acosh(x)

      Compute the inverse hyperbolic cosine of x.

      source

      — Method

      1. atanh(x)

      Compute the inverse hyperbolic tangent of x.

      source

      — Method

      1. asech(x)

      Compute the inverse hyperbolic secant of x.

      source

      — Method

      1. acsch(x)

      Compute the inverse hyperbolic cosecant of x.

      source

      — Method

      1. acoth(x)

      Compute the inverse hyperbolic cotangent of x.

      source

      — Function

      1. sinc(x)

      Compute $\sin(\pi x) / (\pi x)$ if $x \neq 0$, and $1$ if $x = 0$.

      See also cosc, its derivative.

      Base.Math.cosc — Function

      1. cosc(x)

      Compute $\cos(\pi x) / x - \sin(\pi x) / (\pi x^2)$ if $x \neq 0$, and $0$ if $x = 0$. This is the derivative of sinc(x).

      Base.Math.deg2rad — Function

      1. deg2rad(x)

      Convert x from degrees to radians.

      See also: , sind.

      Examples

      1. julia> deg2rad(90)
      2. 1.5707963267948966

      Base.Math.rad2deg — Function

      1. rad2deg(x)

      Convert x from radians to degrees.

      Examples

      1. julia> rad2deg(pi)
      2. 180.0

      Base.Math.hypot — Function

      1. hypot(x, y)

      Compute the hypotenuse $\sqrt{|x|^2+|y|^2}$ avoiding overflow and underflow.

      This code is an implementation of the algorithm described in: An Improved Algorithm for hypot(a,b) by Carlos F. Borges The article is available online at ArXiv at the link

      1. hypot(x...)

      Compute the hypotenuse $\sqrt{\sum |x_i|^2}$ avoiding overflow and underflow.

      See also norm in the LinearAlgebra standard library.

      Examples

      1. julia> a = Int64(10)^10;
      2. julia> hypot(a, a)
      3. 1.4142135623730951e10
      4. julia> √(a^2 + a^2) # a^2 overflows
      5. ERROR: DomainError with -2.914184810805068e18:
      6. sqrt will only return a complex result if called with a complex argument. Try sqrt(Complex(x)).
      7. Stacktrace:
      8. [...]
      9. julia> hypot(3, 4im)
      10. 5.0
      11. julia> hypot(-5.7)
      12. 5.7
      13. julia> hypot(3, 4im, 12.0)
      14. 13.0
      15. julia> using LinearAlgebra
      16. julia> norm([a, a, a, a]) == hypot(a, a, a, a)
      17. true

      Base.log — Method

      1. log(x)

      Compute the natural logarithm of x. Throws for negative Real arguments. Use complex negative arguments to obtain complex results.

      See also [log1p], [log2], [log10].

      Examples

      1. julia> log(2)
      2. 0.6931471805599453
      3. julia> log(-3)
      4. ERROR: DomainError with -3.0:
      5. log will only return a complex result if called with a complex argument. Try log(Complex(x)).
      6. Stacktrace:
      7. [1] throw_complex_domainerror(::Symbol, ::Float64) at ./math.jl:31
      8. [...]

      Base.log — Method

      1. log(b,x)

      Compute the base b logarithm of x. Throws for negative Real arguments.

      Examples

      1. julia> log(4,8)
      2. 1.5
      3. julia> log(4,2)
      4. 0.5
      5. julia> log(-2, 3)
      6. ERROR: DomainError with -2.0:
      7. log will only return a complex result if called with a complex argument. Try log(Complex(x)).
      8. Stacktrace:
      9. [1] throw_complex_domainerror(::Symbol, ::Float64) at ./math.jl:31
      10. [...]
      11. julia> log(2, -3)
      12. ERROR: DomainError with -3.0:
      13. log will only return a complex result if called with a complex argument. Try log(Complex(x)).
      14. Stacktrace:
      15. [1] throw_complex_domainerror(::Symbol, ::Float64) at ./math.jl:31
      16. [...]

      Note

      If b is a power of 2 or 10, or log10 should be used, as these will typically be faster and more accurate. For example,

      1. julia> log(100,1000000)
      2. 2.9999999999999996
      3. julia> log10(1000000)/2
      4. 3.0

      Base.log2 — Function

      1. log2(x)

      Compute the logarithm of x to base 2. Throws for negative Real arguments.

      See also: , ldexp, .

      Examples

      1. julia> log2(4)
      2. 2.0
      3. julia> log2(10)
      4. 3.321928094887362
      5. julia> log2(-2)
      6. ERROR: DomainError with -2.0:
      7. log2 will only return a complex result if called with a complex argument. Try log2(Complex(x)).
      8. Stacktrace:
      9. [1] throw_complex_domainerror(f::Symbol, x::Float64) at ./math.jl:31
      10. [...]

      source

      — Function

      1. log10(x)

      Compute the logarithm of x to base 10. Throws DomainError for negative arguments.

      Examples

      1. julia> log10(100)
      2. 2.0
      3. julia> log10(2)
      4. 0.3010299956639812
      5. julia> log10(-2)
      6. ERROR: DomainError with -2.0:
      7. log10 will only return a complex result if called with a complex argument. Try log10(Complex(x)).
      8. Stacktrace:
      9. [1] throw_complex_domainerror(f::Symbol, x::Float64) at ./math.jl:31
      10. [...]

      source

      — Function

      1. log1p(x)

      Accurate natural logarithm of 1+x. Throws DomainError for arguments less than -1.

      Examples

      1. julia> log1p(-0.5)
      2. -0.6931471805599453
      3. julia> log1p(0)
      4. 0.0
      5. julia> log1p(-2)
      6. ERROR: DomainError with -2.0:
      7. log1p will only return a complex result if called with a complex argument. Try log1p(Complex(x)).
      8. Stacktrace:
      9. [1] throw_complex_domainerror(::Symbol, ::Float64) at ./math.jl:31
      10. [...]

      source

      — Function

      1. frexp(val)

      Return (x,exp) such that x has a magnitude in the interval $[1/2, 1)$ or 0, and val is equal to $x \times 2^{exp}$.

      Examples

      1. julia> frexp(12.8)
      2. (0.8, 4)

      source

      — Method

      1. exp(x)

      Compute the natural base exponential of x, in other words $ℯ^x$.

      See also exp2, and cis.

      Examples

      1. julia> exp(1.0)
      2. 2.718281828459045
      3. julia> exp(im * pi) cis(pi)
      4. true

      Base.exp2 — Function

      1. exp2(x)

      Compute the base 2 exponential of x, in other words $2^x$.

      See also , <<.

      Examples

      1. julia> exp2(5)
      2. 32.0
      3. julia> 2^5
      4. 32
      5. julia> exp2(63) > typemax(Int)
      6. true

      Base.exp10 — Function

      1. exp10(x)

      Compute the base 10 exponential of x, in other words $10^x$.

      Examples

      1. julia> exp10(2)
      2. 100.0
      3. julia> 10^2
      4. 100

      Base.Math.ldexp — Function

      1. ldexp(x, n)

      Compute $x \times 2^n$.

      Examples

      1. julia> ldexp(5., 2)
      2. 20.0

      Base.Math.modf — Function

      1. modf(x)

      Return a tuple (fpart, ipart) of the fractional and integral parts of a number. Both parts have the same sign as the argument.

      Examples

      1. julia> modf(3.5)
      2. (0.5, 3.0)
      3. julia> modf(-3.5)
      4. (-0.5, -3.0)

      Base.expm1 — Function

      1. expm1(x)

      Accurately compute $e^x-1$. It avoids the loss of precision involved in the direct evaluation of exp(x)-1 for small values of x.

      Examples

      1. julia> expm1(1e-16)
      2. 1.0e-16
      3. julia> exp(1e-16) - 1
      4. 0.0

      Base.round — Method

      1. round([T,] x, [r::RoundingMode])
      2. round(x, [r::RoundingMode]; digits::Integer=0, base = 10)
      3. round(x, [r::RoundingMode]; sigdigits::Integer, base = 10)

      Rounds the number x.

      Without keyword arguments, x is rounded to an integer value, returning a value of type T, or of the same type of x if no T is provided. An will be thrown if the value is not representable by T, similar to convert.

      If the keyword argument is provided, it rounds to the specified number of digits after the decimal place (or before if negative), in base base.

      If the sigdigits keyword argument is provided, it rounds to the specified number of significant digits, in base base.

      The r controls the direction of the rounding; the default is RoundNearest, which rounds to the nearest integer, with ties (fractional values of 0.5) being rounded to the nearest even integer. Note that round may give incorrect results if the global rounding mode is changed (see ).

      Examples

      1. julia> round(1.7)
      2. 2.0
      3. julia> round(Int, 1.7)
      4. 2
      5. julia> round(1.5)
      6. 2.0
      7. julia> round(2.5)
      8. 2.0
      9. julia> round(pi; digits=2)
      10. 3.14
      11. julia> round(pi; digits=3, base=2)
      12. 3.125
      13. julia> round(123.456; sigdigits=2)
      14. 120.0
      15. julia> round(357.913; sigdigits=4, base=2)
      16. 352.0

      Note

      Rounding to specified digits in bases other than 2 can be inexact when operating on binary floating point numbers. For example, the Float64 value represented by 1.15 is actually less than 1.15, yet will be rounded to 1.2. For example:

      1. julia> x = 1.15
      2. 1.15
      3. "1.14999999999999991118"
      4. julia> x < 115//100
      5. true
      6. julia> round(x, digits=1)
      7. 1.2

      Extensions

      To extend round to new numeric types, it is typically sufficient to define Base.round(x::NewType, r::RoundingMode).

      Base.Rounding.RoundingMode — Type

      1. RoundingMode

      A type used for controlling the rounding mode of floating point operations (via /setrounding functions), or as optional arguments for rounding to the nearest integer (via the function).

      Currently supported rounding modes are:

      source

      — Constant

      1. RoundNearest

      The default rounding mode. Rounds to the nearest integer, with ties (fractional values of 0.5) being rounded to the nearest even integer.

      source

      — Constant

      1. RoundNearestTiesAway

      Rounds to nearest integer, with ties rounded away from zero (C/C++ round behaviour).

      Base.Rounding.RoundNearestTiesUp — Constant

      1. RoundNearestTiesUp

      Rounds to nearest integer, with ties rounded toward positive infinity (Java/JavaScript behaviour).

      source

      — Constant

      1. RoundToZero

      round using this rounding mode is an alias for .

      source

      — Constant

      1. RoundFromZero

      Rounds away from zero. This rounding mode may only be used with T == BigFloat inputs to round.

      Examples

      1. julia> BigFloat("1.0000000000000001", 5, RoundFromZero)
      2. 1.06

      Base.Rounding.RoundUp — Constant

      1. RoundUp

      using this rounding mode is an alias for ceil.

      Base.Rounding.RoundDown — Constant

      1. RoundDown

      using this rounding mode is an alias for floor.

      Return the nearest integral value of the same type as the complex-valued z to z, breaking ties using the specified RoundingModes. The first is used for rounding the real components while the second is used for rounding the imaginary components.

      Example

      1. julia> round(3.14 + 4.5im)
      2. 3.0 + 4.0im

      source

      — Function

      1. ceil([T,] x)
      2. ceil(x; digits::Integer= [, base = 10])
      3. ceil(x; sigdigits::Integer= [, base = 10])

      ceil(x) returns the nearest integral value of the same type as x that is greater than or equal to x.

      ceil(T, x) converts the result to type T, throwing an InexactError if the value is not representable.

      Keywords digits, sigdigits and base work as for round.

      Base.floor — Function

      1. floor([T,] x)
      2. floor(x; digits::Integer= [, base = 10])
      3. floor(x; sigdigits::Integer= [, base = 10])

      floor(x) returns the nearest integral value of the same type as x that is less than or equal to x.

      floor(T, x) converts the result to type T, throwing an InexactError if the value is not representable.

      Keywords digits, sigdigits and base work as for .

      source

      — Function

      1. trunc([T,] x)
      2. trunc(x; digits::Integer= [, base = 10])
      3. trunc(x; sigdigits::Integer= [, base = 10])

      trunc(x) returns the nearest integral value of the same type as x whose absolute value is less than or equal to the absolute value of x.

      trunc(T, x) converts the result to type T, throwing an InexactError if the value is not representable.

      Keywords digits, sigdigits and base work as for round.

      See also: , floor, , unsafe_trunc.

      Examples

      1. julia> trunc(2.22)
      2. 2.0
      3. julia> trunc(-2.22, digits=1)
      4. -2.2
      5. julia> trunc(Int, -2.22)
      6. -2

      Base.unsafe_trunc — Function

      1. unsafe_trunc(T, x)

      Return the nearest integral value of type T whose absolute value is less than or equal to the absolute value of x. If the value is not representable by T, an arbitrary value will be returned. See also .

      Examples

      1. julia> unsafe_trunc(Int, -2.2)
      2. -2
      3. julia> unsafe_trunc(Int, NaN)
      4. -9223372036854775808

      source

      — Function

      1. min(x, y, ...)

      Return the minimum of the arguments (with respect to isless). See also the function to take the minimum element from a collection.

      Examples

      1. julia> min(2, 5, 1)
      2. 1

      source

      — Function

      1. max(x, y, ...)

      Return the maximum of the arguments (with respect to isless). See also the function to take the maximum element from a collection.

      Examples

      1. julia> max(2, 5, 1)
      2. 5

      source

      — Function

      1. minmax(x, y)

      Return (min(x,y), max(x,y)).

      See also extrema that returns (minimum(x), maximum(x)).

      Examples

      1. julia> minmax('c','b')
      2. ('b', 'c')

      Base.Math.clamp — Function

      1. clamp(x, lo, hi)

      Return x if lo <= x <= hi. If x > hi, return hi. If x < lo, return lo. Arguments are promoted to a common type.

      See also , min, .

      Julia 1.3

      missing as the first argument requires at least Julia 1.3.

      Examples

      1. julia> clamp.([pi, 1.0, big(10)], 2.0, 9.0)
      2. 3-element Vector{BigFloat}:
      3. 3.141592653589793238462643383279502884197169399375105820974944592307816406286198
      4. 2.0
      5. 9.0
      6. julia> clamp.([11, 8, 5], 10, 6) # an example where lo > hi
      7. 3-element Vector{Int64}:
      8. 6
      9. 6
      10. 10

      source

      1. clamp(x, T)::T

      Clamp x between typemin(T) and typemax(T) and convert the result to type T.

      See also .

      Examples

      1. julia> clamp(200, Int8)
      2. 127
      3. julia> clamp(-200, Int8)
      4. -128
      5. julia> trunc(Int, 4pi^2)
      6. 39

      source

      1. clamp(x::Integer, r::AbstractUnitRange)

      Clamp x to lie within range r.

      Julia 1.6

      This method requires at least Julia 1.6.

      Base.Math.clamp! — Function

      1. clamp!(array::AbstractArray, lo, hi)

      Restrict values in array to the specified range, in-place. See also .

      Julia 1.3

      missing entries in array require at least Julia 1.3.

      Examples

      1. julia> row = collect(-4:4)';
      2. julia> clamp!(row, 0, Inf)
      3. 1×9 adjoint(::Vector{Int64}) with eltype Int64:
      4. 0 0 0 0 0 1 2 3 4
      5. julia> clamp.((-4:4)', 0, Inf)
      6. 1×9 Matrix{Float64}:
      7. 0.0 0.0 0.0 0.0 0.0 1.0 2.0 3.0 4.0

      source

      — Function

      1. abs(x)

      The absolute value of x.

      When abs is applied to signed integers, overflow may occur, resulting in the return of a negative value. This overflow occurs only when abs is applied to the minimum representable value of a signed integer. That is, when x == typemin(typeof(x)), abs(x) == x < 0, not -x as might be expected.

      See also: abs2, , sign.

      Examples

      1. julia> abs(-3)
      2. 3
      3. julia> abs(1 + im)
      4. 1.4142135623730951
      5. julia> abs(typemin(Int64))
      6. -9223372036854775808

      Base.Checked.checked_abs — Function

      1. Base.checked_abs(x)

      Calculates abs(x), checking for overflow errors where applicable. For example, standard two’s complement signed integers (e.g. Int) cannot represent abs(typemin(Int)), thus leading to an overflow.

      The overflow protection may impose a perceptible performance penalty.

      Base.Checked.checked_neg — Function

      1. Base.checked_neg(x)

      Calculates -x, checking for overflow errors where applicable. For example, standard two’s complement signed integers (e.g. Int) cannot represent -typemin(Int), thus leading to an overflow.

      The overflow protection may impose a perceptible performance penalty.

      Base.Checked.checked_add — Function

      1. Base.checked_add(x, y)

      Calculates x+y, checking for overflow errors where applicable.

      The overflow protection may impose a perceptible performance penalty.

      Base.Checked.checked_sub — Function

      1. Base.checked_sub(x, y)

      Calculates x-y, checking for overflow errors where applicable.

      The overflow protection may impose a perceptible performance penalty.

      Base.Checked.checked_mul — Function

      1. Base.checked_mul(x, y)

      Calculates x*y, checking for overflow errors where applicable.

      The overflow protection may impose a perceptible performance penalty.

      Base.Checked.checked_div — Function

      1. Base.checked_div(x, y)

      Calculates div(x,y), checking for overflow errors where applicable.

      The overflow protection may impose a perceptible performance penalty.

      Base.Checked.checked_rem — Function

      1. Base.checked_rem(x, y)

      Calculates x%y, checking for overflow errors where applicable.

      The overflow protection may impose a perceptible performance penalty.

      Base.Checked.checked_fld — Function

      1. Base.checked_fld(x, y)

      Calculates fld(x,y), checking for overflow errors where applicable.

      The overflow protection may impose a perceptible performance penalty.

      Base.Checked.checked_mod — Function

      1. Base.checked_mod(x, y)

      Calculates mod(x,y), checking for overflow errors where applicable.

      The overflow protection may impose a perceptible performance penalty.

      Base.Checked.checked_cld — Function

      1. Base.checked_cld(x, y)

      Calculates cld(x,y), checking for overflow errors where applicable.

      The overflow protection may impose a perceptible performance penalty.

      Base.Checked.add_with_overflow — Function

      1. Base.add_with_overflow(x, y) -> (r, f)

      Calculates r = x+y, with the flag f indicating whether overflow has occurred.

      Base.Checked.sub_with_overflow — Function

      1. Base.sub_with_overflow(x, y) -> (r, f)

      Calculates r = x-y, with the flag f indicating whether overflow has occurred.

      Base.Checked.mul_with_overflow — Function

      1. Base.mul_with_overflow(x, y) -> (r, f)

      Calculates r = x*y, with the flag f indicating whether overflow has occurred.

      Base.abs2 — Function

      1. abs2(x)

      Squared absolute value of x.

      Examples

      1. julia> abs2(-3)
      2. 9

      Base.copysign — Function

      1. copysign(x, y) -> z

      Return z which has the magnitude of x and the same sign as y.

      Examples

      1. julia> copysign(1, -2)
      2. -1
      3. julia> copysign(-1, 2)
      4. 1

      Base.sign — Function

      1. sign(x)

      Return zero if x==0 and $x/|x|$ otherwise (i.e., ±1 for real x).

      See also , zero, , flipsign.

      Examples

      1. julia> sign(-4.0)
      2. -1.0
      3. julia> sign(99)
      4. 1
      5. julia> sign(-0.0)
      6. -0.0
      7. julia> sign(0 + im)
      8. 0.0 + 1.0im

      Base.signbit — Function

      1. signbit(x)

      Returns true if the value of the sign of x is negative, otherwise false.

      See also and copysign.

      Examples

      1. julia> signbit(-4)
      2. true
      3. julia> signbit(5)
      4. false
      5. julia> signbit(5.5)
      6. false
      7. julia> signbit(-4.1)
      8. true

      Base.flipsign — Function

      1. flipsign(x, y)

      Return x with its sign flipped if y is negative. For example abs(x) = flipsign(x,x).

      Examples

      1. julia> flipsign(5, 3)
      2. 5
      3. julia> flipsign(5, -3)
      4. -5

      Base.sqrt — Method

      1. sqrt(x)

      Return $\sqrt{x}$. Throws for negative Real arguments. Use complex negative arguments instead. The prefix operator is equivalent to sqrt.

      See also: .

      Examples

      1. julia> sqrt(big(81))
      2. 9.0
      3. julia> sqrt(big(-81))
      4. ERROR: DomainError with -81.0:
      5. NaN result for non-NaN input.
      6. Stacktrace:
      7. [1] sqrt(::BigFloat) at ./mpfr.jl:501
      8. [...]
      9. julia> sqrt(big(complex(-81)))
      10. 0.0 + 9.0im
      11. julia> .√(1:4)
      12. 4-element Vector{Float64}:
      13. 1.0
      14. 1.4142135623730951
      15. 1.7320508075688772
      16. 2.0

      source

      — Function

      1. isqrt(n::Integer)

      Integer square root: the largest integer m such that m*m <= n.

      1. julia> isqrt(5)
      2. 2

      source

      — Function

      1. cbrt(x::Real)

      Return the cube root of x, i.e. $x^{1/3}$. Negative values are accepted (returning the negative real root when $x < 0$).

      The prefix operator is equivalent to cbrt.

      Examples

      1. julia> cbrt(big(27))
      2. 3.0
      3. julia> cbrt(big(-27))
      4. -3.0

      source

      — Function

      1. real(z)

      Return the real part of the complex number z.

      See also: imag, , complex, , Real.

      Examples

      1. julia> real(1 + 3im)
      2. 1

      1. real(T::Type)

      Return the type that represents the real part of a value of type T. e.g: for T == Complex{R}, returns R. Equivalent to typeof(real(zero(T))).

      Examples

      1. julia> real(Complex{Int})
      2. Int64
      3. julia> real(Float64)
      4. Float64

      source

      1. real(A::AbstractArray)

      Return an array containing the real part of each entry in array A.

      Equivalent to real.(A), except that when eltype(A) <: Real A is returned without copying, and that when A has zero dimensions, a 0-dimensional array is returned (rather than a scalar).

      Examples

      1. julia> real([1, 2im, 3 + 4im])
      2. 3-element Vector{Int64}:
      3. 1
      4. 0
      5. 3
      6. julia> real(fill(2 - im))
      7. 0-dimensional Array{Int64, 0}:
      8. 2

      Base.imag — Function

      1. imag(z)

      Return the imaginary part of the complex number z.

      See also: , reim, , angle.

      Examples

      1. julia> imag(1 + 3im)
      2. 3

      1. imag(A::AbstractArray)

      Return an array containing the imaginary part of each entry in array A.

      Equivalent to imag.(A), except that when A has zero dimensions, a 0-dimensional array is returned (rather than a scalar).

      Examples

      1. julia> imag([1, 2im, 3 + 4im])
      2. 3-element Vector{Int64}:
      3. 0
      4. 2
      5. 4
      6. julia> imag(fill(2 - im))
      7. 0-dimensional Array{Int64, 0}:
      8. -1

      source

      — Function

      1. reim(z)

      Return a tuple of the real and imaginary parts of the complex number z.

      Examples

      1. julia> reim(1 + 3im)
      2. (1, 3)

      source

      1. reim(A::AbstractArray)

      Return a tuple of two arrays containing respectively the real and the imaginary part of each entry in A.

      Equivalent to (real.(A), imag.(A)), except that when eltype(A) <: Real A is returned without copying to represent the real part, and that when A has zero dimensions, a 0-dimensional array is returned (rather than a scalar).

      Examples

      1. julia> reim([1, 2im, 3 + 4im])
      2. ([1, 0, 3], [0, 2, 4])
      3. julia> reim(fill(2 - im))
      4. (fill(2), fill(-1))

      Base.conj — Function

      1. conj(z)

      Compute the complex conjugate of a complex number z.

      See also: , adjoint.

      Examples

      1. julia> conj(1 + 3im)
      2. 1 - 3im

      1. conj(A::AbstractArray)

      Return an array containing the complex conjugate of each entry in array A.

      Equivalent to conj.(A), except that when eltype(A) <: Real A is returned without copying, and that when A has zero dimensions, a 0-dimensional array is returned (rather than a scalar).

      Examples

      1. julia> conj([1, 2im, 3 + 4im])
      2. 3-element Vector{Complex{Int64}}:
      3. 1 + 0im
      4. 0 - 2im
      5. 3 - 4im
      6. julia> conj(fill(2 - im))
      7. 0-dimensional Array{Complex{Int64}, 0}:
      8. 2 + 1im

      source

      — Function

      1. angle(z)

      Compute the phase angle in radians of a complex number z.

      See also: atan, .

      Examples

      1. julia> rad2deg(angle(1 + im))
      2. 45.0
      3. julia> rad2deg(angle(1 - im))
      4. -45.0
      5. julia> rad2deg(angle(-1 - im))
      6. -135.0

      source

      — Function

      1. cis(x)

      More efficient method for exp(im*x) by using Euler’s formula: $cos(x) + i sin(x) = \exp(i x)$.

      See also cispi, , exp, .

      Examples

      1. julia> cis(π) -1
      2. true

      source

      — Function

      1. cispi(x)

      More accurate method for cis(pi*x) (especially for large x).

      See also cis, , exp, .

      Examples

      1. julia> cispi(10000)
      2. 1.0 + 0.0im
      3. julia> cispi(0.25 + 1im)
      4. 0.030556854645952924 + 0.030556854645952924im

      Julia 1.6

      This function requires Julia 1.6 or later.

      source

      — Function

      1. binomial(n::Integer, k::Integer)

      The binomial coefficient $\binom{n}{k}$, being the coefficient of the $k$th term in the polynomial expansion of $(1+x)^n$.

      If $n$ is non-negative, then it is the number of ways to choose k out of n items:

      \[\binom{n}{k} = \frac{n!}{k! (n-k)!}\]

      where $n!$ is the factorial function.

      If $n$ is negative, then it is defined in terms of the identity

      \[\binom{n}{k} = (-1)^k \binom{k-n-1}{k}\]

      See also .

      Examples

      1. julia> binomial(5, 3)
      2. 10
      3. julia> factorial(5) ÷ (factorial(5-3) * factorial(3))
      4. 10
      5. julia> binomial(-5, 3)
      6. -35

      External links

      Base.factorial — Function

      1. factorial(n::Integer)

      Factorial of n. If n is an , the factorial is computed as an integer (promoted to at least 64 bits). Note that this may overflow if n is not small, but you can use factorial(big(n)) to compute the result exactly in arbitrary precision.

      See also binomial.

      Examples

      1. julia> factorial(6)
      2. 720
      3. julia> factorial(21)
      4. ERROR: OverflowError: 21 is too large to look up in the table; consider using `factorial(big(21))` instead
      5. Stacktrace:
      6. [...]
      7. julia> factorial(big(21))
      8. 51090942171709440000

      External links

      • on Wikipedia.

      source

      — Function

      1. gcd(x, y...)

      Greatest common (positive) divisor (or zero if all arguments are zero). The arguments may be integer and rational numbers.

      Julia 1.4

      Rational arguments require Julia 1.4 or later.

      Examples

      1. julia> gcd(6, 9)
      2. 3
      3. julia> gcd(6, -9)
      4. 3
      5. julia> gcd(6, 0)
      6. 6
      7. julia> gcd(0, 0)
      8. 0
      9. julia> gcd(1//3, 2//3)
      10. 1//3
      11. julia> gcd(1//3, -2//3)
      12. 1//3
      13. julia> gcd(1//3, 2)
      14. 1//3
      15. julia> gcd(0, 0, 10, 15)
      16. 5

      source

      — Function

      1. lcm(x, y...)

      Least common (positive) multiple (or zero if any argument is zero). The arguments may be integer and rational numbers.

      Julia 1.4

      Rational arguments require Julia 1.4 or later.

      Examples

      1. julia> lcm(2, 3)
      2. 6
      3. julia> lcm(-2, 3)
      4. 6
      5. julia> lcm(0, 3)
      6. 0
      7. julia> lcm(0, 0)
      8. 0
      9. julia> lcm(1//3, 2//3)
      10. 2//3
      11. julia> lcm(1//3, -2//3)
      12. 2//3
      13. julia> lcm(1//3, 2)
      14. 2//1
      15. julia> lcm(1, 3, 5, 7)
      16. 105

      source

      — Function

      1. gcdx(a, b)

      Computes the greatest common (positive) divisor of a and b and their Bézout coefficients, i.e. the integer coefficients u and v that satisfy $ua+vb = d = gcd(a, b)$. $gcdx(a, b)$ returns $(d, u, v)$.

      The arguments may be integer and rational numbers.

      Julia 1.4

      Rational arguments require Julia 1.4 or later.

      Examples

      1. julia> gcdx(12, 42)
      2. (6, -3, 1)
      3. julia> gcdx(240, 46)
      4. (2, -9, 47)

      Note

      Bézout coefficients are not uniquely defined. gcdx returns the minimal Bézout coefficients that are computed by the extended Euclidean algorithm. (Ref: D. Knuth, TAoCP, 2/e, p. 325, Algorithm X.) For signed integers, these coefficients u and v are minimal in the sense that $|u| < |y/d|$ and $|v| < |x/d|$. Furthermore, the signs of u and v are chosen so that d is positive. For unsigned integers, the coefficients u and v might be near their typemax, and the identity then holds only via the unsigned integers’ modulo arithmetic.

      source

      — Function

      1. ispow2(n::Number) -> Bool

      Test whether n is an integer power of two.

      See also count_ones, , nextpow.

      Examples

      1. julia> ispow2(4)
      2. true
      3. julia> ispow2(5)
      4. false
      5. julia> ispow2(4.5)
      6. false
      7. julia> ispow2(0.25)
      8. true
      9. julia> ispow2(1//8)
      10. true

      Julia 1.6

      Support for non-Integer arguments was added in Julia 1.6.

      Base.nextpow — Function

      1. nextpow(a, x)

      The smallest a^n not less than x, where n is a non-negative integer. a must be greater than 1, and x must be greater than 0.

      See also .

      Examples

      1. julia> nextpow(2, 7)
      2. 8
      3. julia> nextpow(2, 9)
      4. 16
      5. julia> nextpow(5, 20)
      6. 25
      7. julia> nextpow(4, 16)
      8. 16

      source

      — Function

      1. prevpow(a, x)

      The largest a^n not greater than x, where n is a non-negative integer. a must be greater than 1, and x must not be less than 1.

      See also nextpow, .

      Examples

      1. julia> prevpow(2, 7)
      2. 4
      3. julia> prevpow(2, 9)
      4. 8
      5. julia> prevpow(5, 20)
      6. 5
      7. julia> prevpow(4, 16)
      8. 16

      source

      — Function

      1. nextprod(factors::Union{Tuple,AbstractVector}, n)

      Next integer greater than or equal to n that can be written as $\prod k_i^{p_i}$ for integers $p_1$, $p_2$, etcetera, for factors $k_i$ in factors.

      Examples

      1. julia> nextprod((2, 3), 105)
      2. 108
      3. julia> 2^2 * 3^3
      4. 108

      Julia 1.6

      The method that accepts a tuple requires Julia 1.6 or later.

      source

      — Function

      1. invmod(n, m)

      Take the inverse of n modulo m: y such that $n y = 1 \pmod m$, and $div(y,m) = 0$. This will throw an error if $m = 0$, or if $gcd(n,m) \neq 1$.

      Examples

      1. julia> invmod(2, 5)
      2. 3
      3. julia> invmod(2, 3)
      4. 2
      5. julia> invmod(5, 6)
      6. 5

      source

      — Function

      1. powermod(x::Integer, p::Integer, m)

      Compute $x^p \pmod m$.

      Examples

      1. julia> powermod(2, 6, 5)
      2. 4
      3. julia> mod(2^6, 5)
      4. 4
      5. julia> powermod(5, 2, 20)
      6. 5
      7. julia> powermod(5, 2, 19)
      8. 6
      9. julia> powermod(5, 3, 19)
      10. 11

      source

      — Function

      1. ndigits(n::Integer; base::Integer=10, pad::Integer=1)

      Compute the number of digits in integer n written in base base (base must not be in [-1, 0, 1]), optionally padded with zeros to a specified size (the result will never be less than pad).

      See also digits, .

      Examples

      1. julia> ndigits(12345)
      2. 5
      3. julia> ndigits(1022, base=16)
      4. 3
      5. julia> string(1022, base=16)
      6. "3fe"
      7. julia> ndigits(123, pad=5)
      8. 5
      9. julia> ndigits(-123)
      10. 3

      source

      — Function

      1. Base.add_sum(x, y)

      The reduction operator used in sum. The main difference from + is that small integers are promoted to Int/UInt.

      Base.widemul — Function

      1. widemul(x, y)

      Multiply x and y, giving the result as a larger type.

      See also , Base.add_sum.

      Examples

      1. julia> widemul(Float32(3.0), 4.0) isa BigFloat
      2. true
      3. julia> typemax(Int8) * typemax(Int8)
      4. 1
      5. julia> widemul(typemax(Int8), typemax(Int8)) # == 127^2
      6. 16129

      Base.Math.evalpoly — Function

      1. evalpoly(x, p)

      Evaluate the polynomial $\sum_k x^{k-1} p[k]$ for the coefficients p[1], p[2], …; that is, the coefficients are given in ascending order by power of x. Loops are unrolled at compile time if the number of coefficients is statically known, i.e. when p is a Tuple. This function generates efficient code using Horner’s method if x is real, or using a Goertzel-like algorithm if x is complex.

      Julia 1.4

      This function requires Julia 1.4 or later.

      Example

      1. julia> evalpoly(2, (1, 2, 3))
      2. 17

      source

      — Macro

      1. @evalpoly(z, c...)

      Evaluate the polynomial $\sum_k z^{k-1} c[k]$ for the coefficients c[1], c[2], …; that is, the coefficients are given in ascending order by power of z. This macro expands to efficient inline code that uses either Horner’s method or, for complex z, a more efficient Goertzel-like algorithm.

      See also evalpoly.

      Examples

      1. julia> @evalpoly(3, 1, 0, 1)
      2. 10
      3. julia> @evalpoly(2, 1, 0, 1)
      4. 5
      5. julia> @evalpoly(2, 1, 1, 1)
      6. 7

      Base.FastMath.@fastmath — Macro

      Execute a transformed version of the expression, which calls functions that may violate strict IEEE semantics. This allows the fastest possible operation, but results are undefined – be careful when doing this, as it may change numerical results.

      This sets the , and corresponds to the -ffast-math option in clang. See the notes on performance annotations for more details.

      Examples

      1. julia> @fastmath 1+2
      2. 3
      3. julia> @fastmath(sin(3))

      Some unicode characters can be used to define new binary operators that support infix notation. For example ⊗(x,y) = kron(x,y) defines the (otimes) function to be the Kronecker product, and one can call it as binary operator using infix syntax: C = A ⊗ B as well as with the usual prefix syntax C = ⊗(A,B).

      Other characters that support such extensions include \odot and \oplus

      The complete list is in the parser code:

      • DK62Donald Knuth, Art of Computer Programming, Volume 2: Seminumerical Algorithms, Sec. 4.6.4.