Missed TensorFlow Dev Summit? Check out the video playlist. Watch recordings

ElementaryFunctions

public protocol ElementaryFunctions

A type that has elementary functions available.

An “elementary function” is a function built up from powers, roots, exponentials, logarithms, trigonometric functions (sin, cos, tan) and their inverses, and the hyperbolic functions (sinh, cosh, tanh) and their inverses.

Conformance to this protocol means that all of these building blocks are available as static functions on the type.

let x: Float = 1
let y = Float.sin(x) // 0.84147096
  • The square root of x.

    For real types, if the argument is negative, either the result is NaN or a precondition failure occurs. For complex types, this function has a branch cut along the negative real axis.

    Declaration

    static func sqrt(_ x: Self) -> Self
  • The cosine of x.

    For real types, x is interpreted as an angle measured in radians.

    Declaration

    static func cos(_ x: Self) -> Self
  • The sine of x.

    For real types, x is interpreted as an angle measured in radians.

    Declaration

    static func sin(_ x: Self) -> Self
  • The tangent of x.

    Declaration

    static func tan(_ x: Self) -> Self
  • The acos function.

    Declaration

    static func acos(_ x: Self) -> Self
  • The asin function.

    Declaration

    static func asin(_ x: Self) -> Self
  • The atan function.

    Declaration

    static func atan(_ x: Self) -> Self
  • The cosh function.

    Declaration

    static func cosh(_ x: Self) -> Self
  • The sinh function.

    Declaration

    static func sinh(_ x: Self) -> Self
  • The tanh function.

    Declaration

    static func tanh(_ x: Self) -> Self
  • The acosh function.

    Declaration

    static func acosh(_ x: Self) -> Self
  • The asinh function.

    Declaration

    static func asinh(_ x: Self) -> Self
  • The atanh function.

    Declaration

    static func atanh(_ x: Self) -> Self
  • The exp function.

    Declaration

    static func exp(_ x: Self) -> Self
  • The exp2 function.

    Declaration

    static func exp2(_ x: Self) -> Self
  • The exp10 function.

    Declaration

    static func exp10(_ x: Self) -> Self
  • The expm1 function.

    Declaration

    static func expm1(_ x: Self) -> Self
  • The log function.

    Declaration

    static func log(_ x: Self) -> Self
  • The log2 function.

    Declaration

    static func log2(_ x: Self) -> Self
  • The log10 function.

    Declaration

    static func log10(_ x: Self) -> Self
  • The log1p function.

    Declaration

    static func log1p(_ x: Self) -> Self
  • exp(y log(x)) computed without loss of intermediate precision.

    For real types, if x is negative the result is NaN, even if y has an integral value. For complex types, there is a branch cut on the negative real axis.

    Declaration

    static func pow(_ x: Self, _ y: Self) -> Self
  • x raised to the nth power.

    Declaration

    static func pow(_ x: Self, _ n: Int) -> Self
  • The nth root of x.

    For real types, if x is negative and n is even, the result is NaN. For complex types, there is a branch cut along the negative real axis.

    Declaration

    static func root(_ x: Self, _ n: Int) -> Self