Funciones elementales

public protocol ElementaryFunctions

Un tipo que tiene funciones elementales disponibles.

Una “función elemental” es una función construida a partir de potencias, raíces, exponenciales, logaritmos, funciones trigonométricas (sin, cos, tanh) y sus inversas, y funciones hiperbólicas (sinh, cosh, tanh) y sus inversas.

La conformidad con este protocolo significa que todos estos bloques de construcción están disponibles como funciones estáticas en el tipo.

let x: Float = 1
let y = Float.sin(x) // 0.84147096
  • La raíz cuadrada de x .

    Para tipos reales, si el argumento es negativo, el resultado es NaN o se produce un error de condición previa. Para tipos complejos, esta función tiene una rama cortada a lo largo del eje real negativo.

    Declaración

    static func sqrt(_ x: Self) -> Self
  • El coseno de x .

    Para tipos reales, x se interpreta como un ángulo medido en radianes.

    Declaración

    static func cos(_ x: Self) -> Self
  • El seno de x .

    Para tipos reales, x se interpreta como un ángulo medido en radianes.

    Declaración

    static func sin(_ x: Self) -> Self
  • La tangente de x .

    Declaración

    static func tan(_ x: Self) -> Self
  • La función acos.

    Declaración

    static func acos(_ x: Self) -> Self
  • La función asín.

    Declaración

    static func asin(_ x: Self) -> Self
  • La función atan.

    Declaración

    static func atan(_ x: Self) -> Self
  • La función cosh.

    Declaración

    static func cosh(_ x: Self) -> Self
  • La función sinh.

    Declaración

    static func sinh(_ x: Self) -> Self
  • La función tanh.

    Declaración

    static func tanh(_ x: Self) -> Self
  • La función acosh.

    Declaración

    static func acosh(_ x: Self) -> Self
  • La función asinh.

    Declaración

    static func asinh(_ x: Self) -> Self
  • La función atanh.

    Declaración

    static func atanh(_ x: Self) -> Self
  • La función exp.

    Declaración

    static func exp(_ x: Self) -> Self
  • La función exp2.

    Declaración

    static func exp2(_ x: Self) -> Self
  • La función exp10.

    Declaración

    static func exp10(_ x: Self) -> Self
  • La función expm1.

    Declaración

    static func expm1(_ x: Self) -> Self
  • La función de registro.

    Declaración

    static func log(_ x: Self) -> Self
  • La función log2.

    Declaración

    static func log2(_ x: Self) -> Self
  • La función log10.

    Declaración

    static func log10(_ x: Self) -> Self
  • La función log1p.

    Declaración

    static func log1p(_ x: Self) -> Self
  • exp(y log(x)) calculado sin pérdida de precisión intermedia.

    Para tipos reales, si x es negativo el resultado es NaN, incluso si y tiene un valor entero. Para tipos complejos, hay un corte de rama en el eje real negativo.

    Declaración

    static func pow(_ x: Self, _ y: Self) -> Self
  • x elevado a la n potencia.

    Declaración

    static func pow(_ x: Self, _ n: Int) -> Self
  • La n ésima raíz de x .

    Para tipos reales, si x es negativo y n es par, el resultado es NaN. Para tipos complejos, hay una rama cortada a lo largo del eje real negativo.

    Declaración

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