tanh


php128 apg

RETURNS the hyperbolic tangent of an argument given in radians.

Compatible with LOCALE only, up to PHP 7.4.XX.





In this function, the following equality is verified:


tanh($num) = sinh($num)/cosh($num)



<?php

float tanh 
( float $num )


where,

$num = The argument to process in radians

?>
 

$num


The argument to process in radians.



  1 EXERCISE   

<table width="100%" border="1" cellspacing="5" cellpadding="5">
<tr><td colspan="4">tanh($num)</td></tr>
<tr><td>DEGREES ( ° )<td>RADIANS ( rd )</td><td>OPERATION</td><td>RESULT</td></tr>

<?php

// setlocale(LC_ALL, 'pt_BR', 'pt-BR');

$pi = M_PI;

$pi_arr01 = [ '-2Л' => -2*$pi, '-Л/4' => -1*$pi/4, 
               
'0' => 0, 'Л/4' => $pi/4, 
               
'Л/2' => $pi/2, '3Л/4' => 3*$pi/4, 'Л' => $pi, '5Л/4' => 5*$pi/4,
               
'3Л/2' => 3*$pi/2, '7Л/4' => 7*$pi/4, '2Л' => 2*$pi ];


foreach(
$pi_arr01 as $val_a => $val_n)
{ 
echo 
'<td>' . rad2deg($val_n) . '</td>';
echo 
'<td>' . $val_a . '</td>';
echo 
'<td>tanh( ' . $val_n . ' )</td>';
echo 
'<td>' . tanh($val_n) . '</td></tr>';

}

?>

<td colspan="4">ed48</td></tr></table>


Function tanh graph

tanh.png apr

  2 EXERCISE   

<?php

// setlocale(LC_ALL, 'pt_BR', 'pt-BR');

$num02a = -1.5707963267949;

$num02b = (sinh($num02a)/cosh($num02a));

$tanh02a = tanh($num02a);

if(
$tanh02a == $num02b)
{
    echo 
'The values of the tested arguments are equal.<br><br>';
    echo 
$tanh02a . ' = ' . $num02b . ' (' . rad2deg($num02a) . '°)<br><br>';
}
else
{
    echo 
'The values of the tested arguments are different.<br><br>';
    echo 
$tanh02a . ' &ne; ' . $num02b . '<br><br>';    
}

?>