Funkcja tanh () w C ++ zwraca hiperboliczną tangens kąta podanego w radianach.
Funkcja jest zdefiniowana w pliku nagłówkowym.
(Matematyka) tanh x = tanh (x) (W programowaniu w C ++)
prototyp tanh () (w standardzie C ++ 11)
podwójne tanh (podwójne x); float tanh (float x); długi podwójny tanh (długi podwójny x); podwójny tanh (T x); // Dla typu całkowitego
Funkcja tanh () przyjmuje jeden argument w radianach, zwraca tangens hiperboliczny tego kąta typu double
, float
lub long double
typu.
Tangens hiperboliczny x jest określony wzorem:
tanh () Parametry
Funkcja tanh () przyjmuje jeden obowiązkowy argument reprezentujący kąt hiperboliczny w radianach.
tanh () Zwracana wartość
Funkcja tanh () zwraca hiperboliczną tangens argumentu.
Przykład 1: Jak funkcja tanh () działa w C ++?
#include #include using namespace std; int main() ( double x = 0.50, result; result = tanh(x); cout << "tanh(x) = " << result << endl; // x in Degrees double xDegrees = 90; x = xDegrees * 3.14159/180; result = tanh(x); cout << "tanh(x) = " << result << endl; return 0; )
Po uruchomieniu programu wynik będzie następujący:
tanh (x) = 0,462117 tanh (x) = 0,917152
Przykład 2: funkcja tanh () z typem całkowitym
#include #include using namespace std; int main() ( int x = 5; double result; result = tanh(x); cout << "tanh(x) = " << result << endl; return 0; )
Po uruchomieniu programu wynik będzie następujący:
tanh (x) = 0,9999909