Skip to content

Modern Math CTanh

Paul Squires edited this page Oct 19, 2026 · 6 revisions

Home › Math Library › Math Library › CTanh

CTanh

Returns the hyperbolic tangent of a complex number.

Syntax

CTanh( byref z as Complex ) as Complex

Notes

  • Routed through CTan — tanh z = -i·tan( iz ) — precisely so that it inherits CTan's overflow guard instead of carrying a second copy of it. A large real part is the case that would otherwise be inf/inf here.
  • Both axes are answered directly, for the accuracy and the signed zeros.
  • Approaches ±1 for a large real part.
  • Spelled with the C prefix because, when this library was a header in namespace FB, a function of the unprefixed name shadowed the intrinsic for every later header — measured, it broke what is now random.tiko — after which the intrinsic could not be called back. The name stayed when the header became std/numeric.

Examples

#import "std/numeric"
using numeric

dim as Complex z = CSet( 3, 4 )

print CToString( CTanh( z ) )               '' 1.000709536067233+0.00490825806749606i
print CToString( CTanh( CSet( 750, 1 ) ) )  '' 1+0i   -- heading for 1, not inf/inf
print CToString( CTanh( CSet( 1, 0 ) ) )    '' 0.7615941559557649+0i   -- exactly the real tanh

Library: Math Library
Category: Math Library
Documented under: Members

Clone this wiki locally