justinethier / cyclone

:cyclone: A brand-new compiler that allows practical application development using R7RS Scheme. We provide modern features and a stable system capable of generating fast native binaries.
http://justinethier.github.io/cyclone/
MIT License
823 stars 42 forks source link

Return complex results when log is passed a negative number #508

Open justinethier opened 1 year ago

justinethier commented 1 year ago

log is not defined on negative real numbers; if a negative value z is passed the result should be computed as though log received the complex number z+0i.

Consider:

cyclone> (log -1)
-nan.0
cyclone> (log -1+0i)
3.14159265358979i

See also: https://docs.scheme.org/surveys/complex-logarithm/