Opened 7 years ago

Closed 6 years ago

#20089 closed defect (invalid)

arc cosine surprising numeric results

Reported by: Ralf Stephan Owned by:
Priority: major Milestone: sage-duplicate/invalid/wontfix
Component: symbolics Keywords:
Cc: Merged in:
Authors: Reviewers:
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Status badges

Description (last modified by Ralf Stephan)

Here under the hood, RR.acos gets called. I think this should return meaningful values even if the value is outside the domain.

sage: cos(1.*I)
1.54308063481524        <--- CC element
sage: acos(_)
1.00000000000000*I
sage: acos(1.54308063481524)
NaN
sage: acos(CC(1.54308063481524))
0.999999999999997*I
sage: acos(RR(1.54308063481524))
NaN

Neither SymPy? nor Pari nor Maxima do this:

In [1]: acos(1.543)
Out[1]: 0.999931383282944⋅ⅈ
? acos(1.543)
%1 = 0.99993138328294395810833497263866793658*I
(%i1) acos(1.543);
(%o1)                        0.9999313832829438 %i

Change History (8)

comment:1 Changed 7 years ago by Ralf Stephan

Description: modified (diff)

comment:2 in reply to:  description Changed 7 years ago by Jeroen Demeyer

Replying to rws:

why are floats of type RR not CC?

Are you suggesting

sage: parent(1.0)
Complex Field with 53 bits of precision

comment:3 Changed 7 years ago by Ralf Stephan

The alternative would be to return complex in RR.acos.

comment:4 Changed 7 years ago by Ralf Stephan

It's also a symptom of inconsistency in symbolic/pynac.pyx where we call RR.function, i.e. mpfr but also mpmath directly. Do you have a preference? Maybe it's best to use mpmath throughout in pynac.pyx.

comment:5 Changed 7 years ago by Ralf Stephan

Description: modified (diff)

I have come to a conclusion, and adapted the ticket description.

comment:6 Changed 6 years ago by Ralf Stephan

Milestone: sage-7.1sage-duplicate/invalid/wontfix
Status: newneeds_review

Ok, since this is at least consistent with arb behaviour I'll file this as oddity not bug. It would be interesting to know what the big Ms return.

comment:7 Changed 6 years ago by Paul Masson

Status: needs_reviewpositive_review

comment:8 Changed 6 years ago by Volker Braun

Resolution: invalid
Status: positive_reviewclosed
Note: See TracTickets for help on using tickets.