Skip to content

Modern Math CLogAbs

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

Home › Math Library › Math Library › CLogAbs

CLogAbs

Returns the logarithm of the modulus, without overflowing for large parts.

Syntax

CLogAbs( byref z as Complex ) as float64

Notes

  • log( CAbs( z ) ) is correct and throws away the range CAbs works to keep. This scales by the larger component and finishes with Log1p, so it survives operands whose square would overflow and is accurate when the modulus is near 1, where the logarithm of a ratio cancels.
  • CLog is built on it, for the same reason.
  • Zero gives -inf, which is log( 0 ) and not an error.
  • AfxNova's, which is GSL's.

Examples

#import "std/numeric"
using numeric

print CLogAbs( CSet( 1e300, 1e300 ) )  '' 691.1221014884936
print CLogAbs( CSet( 3, 4 ) )          '' 1.6094379124341   -- log( 5 )
print CLogAbs( CZero( ) )              '' -1.#INF

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

Clone this wiki locally