acosh

function acosh( x ) --> res

Description

Returns the inverse hyperbolic cosine of x. The inverse hyperbolic cosine is the value whose hyperbolic cosine is x, so acosh( cosh( x ) ) equals x.

Parameters

x

Real number that must be greater or equal to 1.

Return Values

res

The inverse hyperbolic cosine of x or NaN if x < 1.

Code

--ZFUNC-acosh-v1
local function acosh( x ) --> res
   if x < 1 then return math.sqrt( -1 ) end
   return math.log( x + math.sqrt( x+1 ) * math.sqrt( x-1 ) )
end

return acosh

Examples

local t = require( "tapered" )
local acosh = require( "acosh" )
-- util functions
local isnan = require( "isnan" )
local round = require( "round" )

t.is( 0, acosh( 1 ) )
t.is( 2.9932228, round( acosh( 10 ), 7 ) )
t.ok( isnan( acosh( 0 ) ) )

t.done()

See also