Exemple #1
0
        public static ComplexNumber Exp(ComplexNumber exponent)
        {
            if (exponent.IsReal())
            {
                return(Math.Exp(exponent.Real));
            }

            double newRadius = Math.Exp(exponent.Real);
            double newAngle  = exponent.Img;

            return(ComplexNumber.FromPolarCoordinates(newRadius, newAngle));
        }
Exemple #2
0
        public static ComplexNumber Pow(ComplexNumber theBase, ComplexNumber exponent)
        {
            if (exponent.IsReal())
            {
                return(Pow(theBase, exponent.Real));
            }

            double baseRadius = theBase.PolarRadius;
            double baseAngle  = theBase.PolarAngleInRadians;

            double newRadius = Math.Pow(baseRadius, exponent.Real) * Math.Exp(-baseAngle * exponent.Img);
            double newAngle  = exponent.Img * Math.Log(baseRadius) + exponent.Real * baseAngle;

            return(ComplexNumber.FromPolarCoordinates(newRadius, newAngle));
        }
Exemple #3
0
        // same funtionality as below, but more efficient if we know exponent isn't complex
        public static ComplexNumber Pow(ComplexNumber theBase, double exponent)
        {
            if (theBase.Real >= 0 && theBase.IsReal())
            {
                return(Math.Pow(theBase.Real, exponent));
            }

            double baseRadius = theBase.PolarRadius;
            double baseAngle  = theBase.PolarAngleInRadians;

            double newRadius = Math.Pow(baseRadius, exponent);
            double newAngle  = exponent * baseAngle;

            return(ComplexNumber.FromPolarCoordinates(newRadius, newAngle));
        }