pp2@nereida:~/.ssh$ perl -wde 0 main::(-e:1): 0 DB<1> use PDL DB<2> use PDL::Complex DB<3> $x = r2C(-27) # From real to complex DB<4> $r = Croots $x, 3 # There are three complex roots DB<5> print $r # It is sad that there is a bug # with "" overload Use of uninitialized value in numeric ... [ 1.5 +2.59807621135332i -3 +3.67381906146713e-16i 1.5 -2.59807621135332i ] DB<6> x $ra # The answer is a PDL object 0 PDL::Complex=SCALAR(0x8a6a0a8) -> 144899352 DB<7> p re $r # Get the "real" components [1.5 -3 1.5] DB<8> p im $r # And the imaginary ones: [ 2.5980762 3.6738191e-16 -2.5980762] DB<9> $y = $r ** 3 # Check the solution: DB<10> p re $y [-27 -27 -27] DB<11> p im $y # Almost 0, as expected [3.3064372e-15 9.9193115e-15 6.8636015e-14]