tanh

 

Description

Calculate the hyperbolic tangent for both real and complex number.

Syntax

double tanh( double x )
complex tanh( complex x )

Parameters

x
[input] Real or complex angle in radians.

Return

The tanh returns the hyperbolic tangent of x.

Examples

EX1

//This program computes and displays the sines of x.

#include <origin.h>

int test_tanh()
{
    double vv;
    vv = tanh(0);        //output should be tanh(0) =0
    out_double("tanh(0) =", vv);
    ASSERT( is_equal(vv, 0) );
    vv = tanh(4.567898);
    out_double("tanh(4.567898) =", vv);    //output should be tanh(4.567898) =0.99978
    ASSERT( is_equal(round(vv,5), 0.99978) );
    vv = tanh(-0.98765);
    out_double("tanh(-0.98765) =", vv);    //output should be tanh(-0.98765) =-0.75636
    ASSERT( is_equal(round(vv,5), -0.75636) );
    
    return 1;
}

EX2

#include <Origin.h>

#define PI 3.1415
int test_tanh()
{
    complex vv;
    vv = tanh(0);        
    out_complex("tanh(0) =", vv);  //output should be tanh(0) = 0.000000+0.000000i
    vv = tanh(2*PI*1i/3)^2;
    //output should be tanh(2*PI*1i/3)^2 = -3.000856-0.000000i
    out_complex("tanh(2*PI*1i/3)^2 =", vv);    
    return 1;
}

Remark

See Also

tan, atan

header to Include

origin.h

Reference