coth

function coth( x ) --> res

Description

Returns the hyperbolic cotangent of the hyperbolic angle x.

Parameters

x

An angle in radians.

Return Values

res

Hyperbolic cotangent of x.

Code

--ZFUNC-coth-v1
local function coth( x ) --> res
   --ZFUNC-tanh-v1
   local function tanh( x )
      --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 1 / tanh( x );
end

return coth

Examples

local t = require( "taptest" )
local coth = require( "coth" )
local round = require( "round" )

t( round( coth( 2 ), 7 ), 1.0373147 )

t()

Inspired by

See also