/// <summary>
        /// Evaluate all cubic roots of this <c>Complex</c>.
        /// </summary>
        public static (Complex, Complex, Complex) CubicRoots(this Complex complex)
        {
            var          r     = Math.Pow(complex.Magnitude, 1d / 3d);
            var          theta = complex.Phase / 3;
            const double shift = Constants.Pi2 / 3;

            return(Complex.FromPolarCoordinates(r, theta),
                   Complex.FromPolarCoordinates(r, theta + shift),
                   Complex.FromPolarCoordinates(r, theta - shift));
        }
Example #2
0
        /// <summary>
        /// Evaluate all cubic roots of this <c>Complex</c>.
        /// Modified from https://github.com/mathnet/mathnet-numerics/blob/master/src/Numerics/ComplexExtensions.cs
        /// </summary>
        public static (Complex, Complex, Complex) ComplexCubeRoot(Complex complex)
        {
            double       r     = Math.Pow(complex.Magnitude, 1.0 / 3.0);
            double       theta = complex.Phase / 3.0;
            const double shift = Math.PI * 2.0 / 3.0;

            return(Complex.FromPolarCoordinates(r, theta),
                   Complex.FromPolarCoordinates(r, theta + shift),
                   Complex.FromPolarCoordinates(r, theta - shift));
        }