Repository navigation
Modern Math CAtan
Paul Squires edited this page Oct 19, 2026
·
5 revisions
Home › Math Library › Math Library › CAtan
Returns the inverse tangent of a complex number.
CAtan( byref z as Complex ) as Complex- The logarithmic form,
(i/2)·( Log( 1 - iz ) - Log( 1 + iz ) ), which is well conditioned — the cancellation that ruins the naive arcsine does not arise for the arctangent. -
The cuts are on the imaginary axis beyond ±i, and the log form cannot see which side of one it is on: forming
1 + izadds+0.0to-0.0, and IEEE resolves that to+0.0, destroying the sign bit that decides. So that segment is answered directly. -
The whole imaginary axis is, in fact, and not only for the sign: the log form cancels for a small argument and gave
atan( 1e-8·i )as9.999999994736e-9for an answer that is1e-8. -
CAtan( 0 )is exactly zero.
#import "std/numeric"
using numeric
print CToString( CAtan( CSet( 0.5, 0.25 ) ) ) '' 0.4842544903299662+0.2005866181312343i
print CToString( CAtan( CSet( 0, 2 ) ) ) '' 1.5707963267948966+0.5493061443340549i -- on the cut, above it
print CToString( CAtan( CSet( -0.0, 2 ) ) ) '' -1.5707963267948966+0.5493061443340549i -- below it
print CImag( CAtan( CSet( 0, 1e-8 ) ) ) '' 1e-008 -- exactly 1e-8, where the log form cancelsLibrary: Math Library
Category: Math Library
Documented under: Members
tiko-lang · Home · Feature Index · Keyword Index · License
FreeBASIC manual pages reproduced under the GNU FDL 1.3.
- Generics
- Interfaces
- For Each
- Iterators
- Tuples
- Array Results
- Defer
- Lambdas
- Block Strings
- Partial Types
- String Slices
- Embed
- Typed Variadics
- C Header Import
- Foreign Library Linking
- UString
- Fixed-Width Types
- Nullptr
- String Library
- Format
- Array
- Map
- Set
- LinkedList
- OrderedMap
- OrderedSet
- Sorting
- Optional
- Result
- Smart Pointers
- Date and Time (Chrono)
- Filesystem
- File Streams
- Config (INI and TOML)
- Codec
- Hash
- UUID
- OS
- Process
- Net
- HTTP and TLS
- Math Library
- Finance
- Logging
- Terminal TUI Library
- PsControls
- tkControls
- sys/win
- Goroutines and Channels
- LLVM Backend
- tiko build
- TIKO_COMPILER
- Variable Declarations
- Standard Data Types
- User Defined Types
- Procedures
- Operators
- Control Flow Statements
- Converting Data Types
- Array Functions
- String Functions
- Mathematical Functions
- Bit Manipulation
- Date and Time Functions
- File I/O Functions
- Console Functions
- User Input (Runtime Library)
- User Input Functions (Graphics Library)
- Screen Functions
- 2D Drawing Functions
- Graphics Library Reference
- Graphics Keyword List
- Memory Functions
- Threading Support Functions
- Error Handling Functions
- Operating System Functions
- Preprocessor
- Intrinsic Defines
- Miscellaneous Keywords
- Modularizing