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( "tapered" )
local coth = require( "coth" )
-- util functions
local round = require( "round" )

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

t.done()

Inspired by

See also