Ticket #3576 (closed defect: fixed)

Opened 5 years ago

Last modified 5 years ago

[with patch; positive review] stupid bug in RDF

Reported by: was Owned by: somebody
Priority: blocker Milestone: sage-3.0.4
Component: basic arithmetic Keywords:
Cc: Work issues:
Report Upstream: Reviewers:
Authors: Merged in:
Dependencies: Stopgaps:

Description

This is sad:

sage: RDF(-1).nth_root(2)

Look at the dumb code in real_double.pyx:

    def nth_root(self, int n):
        """
        Returns the $n^{th}$ root of self.
        EXAMPLES:
            sage: r = RDF(-125.0); r.nth_root(3)
            -5.0
            sage: r.nth_root(5)
            -2.6265278044
        """
        if n == 0:
            return RealDoubleElement(float('nan'))
        if self._value < 0 and GSL_IS_EVEN(n):
            pass #return self._complex_double_().pow(1.0/n)
        else:
            return RealDoubleElement(self.__nth_root(n))

Amazingly this was introduced in the very first patch by Tom Boothby in 2006 and nobody ever noticed!!

Attachments

sage-3576.patch Download (2.9 KB) - added by was 5 years ago.

Change History

comment:1 Changed 5 years ago by was

This is also bad, bad, bad:

sage: RDF(-1).nth_root(5)^(5)
-1.35861063971

Changed 5 years ago by was

comment:2 Changed 5 years ago by was

  • Summary changed from stupid bug in RDF to [with patch; needs review] stupid bug in RDF

comment:3 Changed 5 years ago by mhansen

  • Summary changed from [with patch; needs review] stupid bug in RDF to [with patch; positive review] stupid bug in RDF

The code is definitely much better style and correctness-wise after the patch.

+1

comment:4 Changed 5 years ago by mabshoff

  • Status changed from new to closed
  • Resolution set to fixed

Merged in Sage 3.0.4.alpha2

comment:5 Changed 5 years ago by boothby

wow I'm dumb!

Note: See TracTickets for help on using tickets.