public Complex log() {
        double rpart = Math.sqrt(re * re + im * im);
        double ipart = Math.atan2(im, re);
        if(ipart > Math.PI) {
            ipart = ipart - 2.0 * Math.PI;
        }
        return new Complex(Math.log(rpart), ipart);
    }