HP-71B: 1^Inf Error
|
06-09-2023, 02:22 PM
(This post was last modified: 06-10-2023 01:09 PM by Albert Chan.)
Post: #8
|
|||
|
|||
RE: HP-71B: 1^Inf Error
(06-09-2023 01:03 PM)J-F Garnier Wrote: In this particular example [acos(2+0j)], the signed zero is not managed properly in the complex domain. I believe it is asin/acos sign bug in code. Calculate acos(2+0j) by "hand", I am getting correct answer. Implementing the complex arcsine and arccosine functions ... (page 326 for acos(z) algorithm), lua> x, y = 2, 0 lua> signy = signbit(y) and -1 or 1 lua> r = sqrt((x+1)^2 + y^2) lua> s = sqrt((x-1)^2 + y^2) lua> a = (r+s)/2 lua> b = x/a lua> I.new(acos(b), -signy * acosh(a)) -- = acos(2+0j) (0-1.3169578969248166*I) sign(y) bug is in cpr.a, which sometimes use -sign(x) instead. (docasc code comment) Because asin(z) + acos(z) = pi/2, this bug affected both asin and acos. Code: * with sign(y,x)=sign(y) if y<>0, -sgn(x) if y=0 >acos((2,0)) (0,1.31695789692) ✘ >acos((-2,0)) (3.14159265359,-1.31695789692) ✔ |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 2 Guest(s)