tanh
function tanh( x ) --> res
Description
Returns the hyperbolic tangent of x.
Paramters
- x
-
An angle in radians.
Return Values
- res
-
The hyperbolic tangent of x.
Code
--ZFUNC-tanh-v1 local function tanh( x ) --> res --ZFUNC-cosh-v1 local function cosh( x ) return ( math.exp( x ) + math.exp( -x ) ) / 2 end --ZFUNC-sinh-v1 local function sinh( x ) return ( math.exp( x ) - math.exp( -x ) ) / 2 end return sinh( x ) / cosh( x ) end return tanh
Examples
local t = require( "taptest" ) local round = require( "round" ) local tanh = require( "tanh" ) t( round( tanh( -2 ), 6 ), -0.964028 ) t( round( tanh( 0 ), 1 ), 0 ) t( round( tanh( 0.5 ), 6 ), 0.462117 ) t()