Compartilhar via


tanh, tanhf, tanhl

Calcula a tangente hiperbólica.

Sintaxe

double tanh( double x );
float tanhf( float x );
long double tanhl( long double x );
#define tanh(x) // Requires C11 or higher
float tanh( float x );  // C++ only
long double tanh( long double x );  // C++ only

Parâmetros

x
Ângulo em radianos.

Retornar valor

As funções tanh retornam a tangente hiperbólica de x. Não há retorno de erro.

Entrada Exceção SEH Exceção _matherr
± QNaN, IND nenhum _DOMAIN

Comentários

Como C++ permite sobrecargas, é possível chamar sobrecargas de tanh e que utilizam e retornam valores de float ou long double. Em um programa do C, a menos que você esteja usando a macro <tgmath.h> para chamar essa função, tanh sempre recebe e retorna um double.

Se você usar a tanh macro de <tgmath.h>, o tipo do argumento determinará qual versão da função será selecionada. Confira Matemática do tipo genérico para obter detalhes.

Por padrão, o estado global dessa função tem como escopo o aplicativo. Para alterar esse comportamento, consulte Estado global na CRT.

Requisitos

Rotina Cabeçalho necessário (C) Cabeçalho necessário (C)
tanh, tanhf, tanhl <math.h> <cmath> ou <math.h>
Macro tanh <tgmath.h>

Para obter informações sobre compatibilidade, consulte Compatibilidade.

Exemplo

// crt_tanh.c
// This program displays the tangent of pi / 4
// and the hyperbolic tangent of the result.
// Compile by using: cl crt_tanh.c

#include <math.h>
#include <stdio.h>

int main( void )
{
   double pi = 3.1415926535;
   double x, y;

   x = tan( pi / 4 );
   y = tanh( x );
   printf( "tan( %f ) = %f\n", pi/4, x );
   printf( "tanh( %f ) = %f\n", x, y );
}
tan( 0.785398 ) = 1.000000
tanh( 1.000000 ) = 0.761594

Confira também

Suporte a matemática e ponto flutuante
acosh, acoshf, acoshl
asinh, asinhf, asinhl
atanh, atanhf, atanhl
cosh, coshf, coshl
sinh, sinhf, sinhl