Skip to content

incorrect power calculation #587

@metelev-sv

Description

@metelev-sv

Hello!
mpmath.power() fails with negative numbers. Initially I expect to have something like -8**(1./3)=-2. In reality there are 3 roots for 1./3 power and ok, let it be some other answer. But why I didn't get exact 1.0 as a real part and exact sqrt(3) as imaginary part?

$ python3
Python 3.8.5 (default, Jan 27 2021, 15:41:15)
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.

import mpmath
mpmath.mp.dps=50
mpmath.power(-8.0,1./3)
mpc(real='1.0000000000000000622086928455818618679774324989807018', imag='1.7320508075688771687514964885913910681346917057935831')
mpmath.sqrt(3)
mpf('1.732050807568877293527446341505872366942805253810381')

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions