Opened 4 years ago

Closed 3 years ago

#20089 closed defect (invalid)

arc cosine surprising numeric results

Reported by: rws 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:

Description (last modified by rws)

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 4 years ago by rws

  • Description modified (diff)

comment:2 in reply to: ↑ description Changed 4 years ago by jdemeyer

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 4 years ago by rws

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

comment:4 Changed 4 years ago by rws

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 4 years ago by rws

  • Description modified (diff)

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

comment:6 Changed 3 years ago by rws

  • Milestone changed from sage-7.1 to sage-duplicate/invalid/wontfix
  • Status changed from new to needs_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 3 years ago by paulmasson

  • Status changed from needs_review to positive_review

comment:8 Changed 3 years ago by vbraun

  • Resolution set to invalid
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.