Project

General

Profile

Actions

Bug #3563

closed

problems with exponentiation, cbrt

Added by kolbrich (Kevin Olbrich) over 14 years ago. Updated over 13 years ago.

Status:
Closed
Target version:
-
ruby -v:
ruby 1.9.2dev (2010-07-02 revision 28524) [i386-darwin9.8.0]
Backport:
[ruby-core:31234]

Description

=begin

nothing required

(-27)**(Rational(1,3)) #=> (1.5000000000000004+2.598076211353316i)

I would expect that this would return -3

Complex(1.5000000000000004,2.598076211353316)**3 #=> (-27.000000000000007+1.2434497875801753e-14i)

I can understand how this might happen given round off errors, but the following identity should be true

Math.cbrt(-27) == (-27)**(Rational(1,3)) #=> false

Also note that if you do this...

require 'complex'
Math.cbrt(-27) #=> (1.5000000000000004+2.598076211353316i)
=end

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0