Repository navigation
Modern Math CAsin
Paul Squires edited this page Oct 19, 2026
·
5 revisions
Home › Math Library › Math Library › CAsin
Returns the inverse sine of a complex number, or of any real number.
CAsin( byref z as Complex ) as Complex
CAsin( byval x as float64 ) as Complex-
The Hull–Fairgrieve–Tang method, transcribed from .NET's
Asin_Internal. The textbook-i·Log( iz + CSqrt( 1 - z² ) )cancels catastrophically near the branch points at ±1, which is exactly where an inverse sine is most often evaluated. This does not. -
Exactly ±1 on the real axis is answered directly.
Asin_Internaldivides by zero there — itstterm contains1/( s + ( x - 1 ) )andsis zero — so .NET's ownAsin( 1 )is NaN rather than π/2. -
The cuts are the real axis beyond ±1, and the sign of a zero imaginary part decides the side. .NET tests
imaginary < 0.0here, and a negative zero is not less than zero, so .NET lands on the wrong branch for half the axis: itsAsin( 2 - 0i )has a positive imaginary part where C99 gives a negative one. This tests the sign bit. - The
float64overload exists because the real arcsine is undefined outside[-1, 1]while the complex one is not —CAsin( 2.0 )is a perfectly ordinary complex number. AfxNova spelled itCArcSinReal. -
CSin( CAsin( z ) )returnszon the principal strip.
#import "std/numeric"
using numeric
print CToString( CAsin( CSet( 0.5, 0.25 ) ) ) '' 0.5016088532755009+0.2813960562452928i
print CToString( CAsin( CSet( 1, 0 ) ) ) '' 1.5707963267948966+0i -- PI/2 -- .NET's own Asin gives NaN here
print CToString( CAsin( 2.0 ) ) '' 1.5707963267948966+1.3169578969248166i -- the double overload
print CToString( CAsin( CSet( 2, -0.0 ) ) ) '' 1.5707963267948966-1.3169578969248166i -- the other side of the cutLibrary: 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
- 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