#lang racket (require math/base) (define-syntax-rule (tst x ...) (begin (let ((y (string->number 'x))) (printf "~a ~s ~s ~s~n" 'x y (atanh y) (real? y))) ...)) (tst "-2" "-2+0i" "-2+0.0i" "-2.0" "-2.0+0i" "-2.0+0.0i")
Produces -2 -2 +nan.0 #t -2+0i -2 +nan.0 #t -2+0.0i -2.0+0.0i -0.5493061443340549+1.5707963267948966i #f -2.0 -2.0 +nan.0 #t -2.0+0i -2.0 +nan.0 #t -2.0+0.0i -2.0+0.0i -0.5493061443340549+1.5707963267948966i #f It seems to me that the problem occurs only when the argument is a real, incuding complex numbers with exact zero imaginary part, which, IIRC, are considered to be reals too. Notice that when the imiginary part is inexact, the real part is presented as inexact too. Is there a reason why atanh cannot convert its argument to a complex number with inexact imaginary part before computing the atanh? May be that for some exact arguments atanh must produce an exact result? (like (sqrt 4) produces an exact result, which is nice) Jos -----Original Message----- From: racket-users@googlegroups.com [mailto:racket-users@googlegroups.com] On Behalf Of Robby Findler Sent: miƩrcoles, 07 de octubre de 2015 17:11 To: Tony Garnock-Jones Cc: Brian Adkins; Racket Users Subject: Re: [racket-users] (atanh -2) -> +nan.0 They are the same number, no? -> (= (make-rectangular -2 0) -2) #t -> (complex? -2) #t Robby On Wed, Oct 7, 2015 at 10:07 AM, Tony Garnock-Jones <to...@ccs.neu.edu> wrote: > On 10/07/2015 10:19 AM, Brian Adkins wrote: >> If I instead call: (atanh (number->float-complex -2)) I do get a >> complex result. > > I was surprised to see that (atanh (make-rectangular -2 0)) => +nan.0. > > -- > You received this message because you are subscribed to the Google Groups "Racket Users" group. > To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.