Date: Sun, 12 Aug 2012 23:02:44 -0000 From: Stephen Montgomery-Smith <stephen@missouri.edu> To: Peter Jeremy <peter@rulingia.com> Cc: Diane Bruce <db@db.net>, Bruce Evans <brde@optusnet.com.au>, John Baldwin <jhb@freebsd.org>, David Chisnall <theraven@freebsd.org>, Bruce Evans <bde@freebsd.org>, Steve Kargl <sgk@troutmask.apl.washington.edu>, David Schultz <das@freebsd.org>, Warner Losh <imp@bsdimp.com> Subject: Re: Use of C99 extra long double math functions after r236148 Message-ID: <500DAD41.5030104@missouri.edu> Resent-Message-ID: <20120812230235.GC20453@server.rulingia.com> In-Reply-To: <20120722121219.GC73662@server.rulingia.com> References: <20120717084457.U3890@besplex.bde.org> <5004A5C7.1040405@missouri.edu> <5004DEA9.1050001@missouri.edu> <20120717040118.GA86840@troutmask.apl.washington.edu> <20120717042125.GF66913@server.rulingia.com> <20120717043848.GB87001@troutmask.apl.washington.edu> <20120717225328.GA86902@server.rulingia.com> <20120717232740.GA95026@troutmask.apl.washington.edu> <20120718001337.GA87817@server.rulingia.com> <20120718123627.D1575@besplex.bde.org> <20120722121219.GC73662@server.rulingia.com>
next in thread | previous in thread | raw e-mail | index | archive | help
This is a multi-part message in MIME format. --------------060606060301090803040905 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit I just realized that catan(z) = reverse( catanh(reverse (z))), just like casin relates to casinh (remember reverse(x+I*y) = y+I*x). This is a consequence of catan and catanh being odd functions, as well as the standard relation catan(z) = -I*catanh(I*z). So I would modify Peter's code by taking out the minus signs. Maybe it would make a difference if the answers involved -0. On 07/22/12 07:12, Peter Jeremy wrote: > /* > * Arc-tangent of a complex argument z = x + I*y. > * > * catan(z) = reverse( catanh(reverse (z))) > * > */ > double complex > catan(double complex z) > { > double complex r; > > r = catanh(cpack(cimag(z), creal(z))); > return (cpack(cimag(r), creal(r))); > } > I am attaching code that computes all six arc-trig-hyp functions. Peter made a remark that catanh(z) would be hard to compute when |z|=1. Fortunately that is not the case, because when |z|=1, the imaginary part of catanh(z) is plus or minus PI/4. So we won't face the same problems that clog(z) has. I feel that I am done with these functions for now. I tried to change my comments to conform to the style given to me by Bruce. However spacing inside mathematical expressions is something where I am inconsistent. The functions still need a lot of work to handle -0, infs and NaNs correctly. I will leave that to you guys, because you seem so much better at it than me. I still don't understand why the proper test is "if (x!=x) return(x+x)" rather than "if (isnan(x)) return(NAN)". However, I think you might find that a lot of the handling when the input or output is infinity works without any changes. For example, catanh(1) seems to produce the correct answer, and maybe even catanh(1-0*I) will work better than expected. I am also attaching the test code. I run it like this, so that only ULPs greater than 3 appear: ./test3 | perl -lne '@a=split " ",$_;print if $a[2]>3 || $a[3]>3' and get outputs like this: 21987 atanh 3.13643 0.299452 0.443282 0.0665108 0.473296 0.0824781 67013 atan 0.377411 3.03922 -0.0170315 -0.442191 -0.0211662 -0.474753 70044 acosh 0.883474 3.23108 1.06353 0.107343 0.433696 0.242278 70044 acos 3.23108 0.883474 1.06353 0.107343 0.242278 -0.433696 96124 atan 0.509279 3.21631 -0.0346851 -0.461121 -0.0440054 -0.497841 The first example is the count of which example I am trying. The third and fourth entries are the ULPs of the real and imaginary parts of the answer. The 5th and 6th entries are the real and imaginary parts of the input, and the 7th and 8th entries are the real and imaginary parts of the answer. I use the unuran port to generate data where the x and y values of the inputs are normally distributed N(0,1). As you can see from the parts I commented out, I tried many variations (mostly to check edge cases: close to zero, very large, or close to branch cuts). In particular, if you want random data on the unit disk, use h=hypot(x,y); x/=h; y/=h; My next project will be to get clog(z) to work well when |z|=1. Stephen --------------060606060301090803040905 Content-Type: text/plain; charset=us-ascii; name="catrig.c" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="catrig.c" I2luY2x1ZGUgPGNvbXBsZXguaD4KI2luY2x1ZGUgPGZsb2F0Lmg+CiNpbmNsdWRlIDxtYXRo Lmg+CgojaW5jbHVkZSAibWF0aF9wcml2YXRlLmgiCgovKgogKiBnY2MgZG9lc24ndCBpbXBs ZW1lbnQgY29t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JcnkgPSBhdGFuMigtMiwgeSkvMjsKCX0gZWxzZSBpZiAoZmFicyh5KSA8IDFlLTEw MCkgewoJCWlmIChodWdlK3g+b25lKSAvKiBzZXQgaW5leGFjdCBmbGFnLiAqLwoJCQlyeSA9 IGF0YW4yKDIqeSwgKDEteCkqKDEreCkpLzI7Cgl9IGVsc2UKCQlyeSA9IGF0YW4yKDIqeSwg KDEteCkqKDEreCkteSp5KS8yOwoKCXJldHVybiBjcGFjayhyeCxyeSk7Cn0KCi8qCiAqIGNh dGFuKHopID0gcmV2ZXJzZShjYXRhbmgocmV2ZXJzZSh6KSkpCiAqIHdoZXJlIHJldmVyc2Uo eCtJKnkpID0geSt4KkkgPSBJKmNvbmooeCtJKnkpLgogKi8KCmRvdWJsZSBjb21wbGV4CmNh dGFuKGRvdWJsZSBjb21wbGV4IHopCnsKCWNvbXBsZXggcmVzdWx0OwoKCXJlc3VsdCA9IGNh dGFuaChjcGFjayhjaW1hZyh6KSxjcmVhbCh6KSkpOwoJcmV0dXJuIGNwYWNrKGNpbWFnKHJl c3VsdCksY3JlYWwocmVzdWx0KSk7Cn0K --------------060606060301090803040905 Content-Type: text/plain; charset=us-ascii; name="test3.c" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="test3.c" I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxzdGRsaWIuaD4KI2luY2x1ZGUgPHN5cy9j ZGVmcy5oPgojaW5jbHVkZSA8ZmxvYXQuaD4KI2luY2x1ZGUgPGZlbnYuaD4KI2luY2x1ZGUg ImNvbXBsZXguaCIKI2luY2x1ZGUgIm1hdGguaCIKI2luY2x1ZGUgIm1hdGhfcHJpdmF0ZS5o IgojaW5jbHVkZSAibXBmci5oIgojaW5jbHVkZSAibXBjLmgiCiNpbmNsdWRlIDx1bnVyYW4u aD4KCmNvbXBsZXggZG91YmxlIGNhc2luaChjb21wbGV4IGRvdWJsZSB6KTsKY29tcGxleCBk b3VibGUgY2FzaW4oY29tcGxleCB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nQoZ2VuKTsKKi8KCiAgICBjb3VudCsrOwogICAgZXZhbCh4LHksY2FzaW5oLG1wY19hc2lu aCwmcngsJnJ5LCZleCwmZXkpOwogICAgcHJpbnRmKCIlZCBhc2luaCAlZyAlZyAlZyAlZyAl ZyAlZ1xuIixjb3VudCxleCxleSx4LHkscngscnkpOwogICAgZXZhbCh4LHksY2Fjb3NoLG1w Y19hY29zaCwmcngsJnJ5LCZleCwmZXkpOwogICAgcHJpbnRmKCIlZCBhY29zaCAlZyAlZyAl ZyAlZyAlZyAlZ1xuIixjb3VudCxleCxleSx4LHkscngscnkpOwogICAgZXZhbCh4LHksY2F0 YW5oLG1wY19hdGFuaCwmcngsJnJ5LCZleCwmZXkpOwogICAgcHJpbnRmKCIlZCBhdGFuaCAl ZyAlZyAlZyAlZyAlZyAlZ1xuIixjb3VudCxleCxleSx4LHkscngscnkpOwogICAgZXZhbCh4 LHksY2FzaW4sbXBjX2FzaW4sJnJ4LCZyeSwmZXgsJmV5KTsKICAgIHByaW50ZigiJWQgYXNp biAlZyAlZyAlZyAlZyAlZyAlZ1xuIixjb3VudCxleCxleSx4LHkscngscnkpOwogICAgZXZh bCh4LHksY2Fjb3MsbXBjX2Fjb3MsJnJ4LCZyeSwmZXgsJmV5KTsKICAgIHByaW50ZigiJWQg YWNvcyAlZyAlZyAlZyAlZyAlZyAlZ1xuIixjb3VudCxleCxleSx4LHkscngscnkpOwogICAg ZXZhbCh4LHksY2F0YW4sbXBjX2F0YW4sJnJ4LCZyeSwmZXgsJmV5KTsKICAgIHByaW50Zigi JWQgYXRhbiAlZyAlZyAlZyAlZyAlZyAlZ1xuIixjb3VudCxleCxleSx4LHkscngscnkpOwog IH0KfQo= --------------060606060301090803040905--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?500DAD41.5030104>