tanh() function

The tanh() function takes a single mandatory argument representing a hyperbolic angle in radian.

The tanh() function returns the hyperbolic tangent of the argument.

Example 1: In radians

Input:  x = 0.5
Output: 0.462117

Example 2: In degrees

Input:  degrees = 90
Output: 0.917026

Approach 1: In radians

C++

#include <bits/stdc++.h>
using namespace std;

int main()
{
    double x = 0.5;

    cout << tanh(x);

    return 0;
}

Approach 2: In degrees

C++

#include <bits/stdc++.h>
using namespace std;

int main()
{
    double degrees = 90;
    double x = degrees * 3.14 / 180;

    cout << tanh(x);

    return 0;
}


No comments:

Post a Comment