Exemple #1
0
        /// <summary>
        /// Returns the cosine of the specified complex function argument z.
        /// </summary>
        /// <param name="z">Function argument.</param>
        /// <returns>The cosine of the specified complex function argument z.</returns>
        public static ComplexFloat Cos(ComplexFloat z)
        {
            double ezi = Math.Exp(z.Im);
            double inv = 1.0 / ezi;

            return(ComplexFloat.FromRealImaginary((float)(0.5 * Math.Cos(z.Re) * (inv + ezi)), (float)(0.5 * Math.Sin(z.Re) * (inv - ezi))));
        }
Exemple #2
0
        /// <summary>
        /// Returns the tangent of the specified complex function argument z.
        /// </summary>
        /// <param name="z">Function argument.</param>
        /// <returns>The tangent of the specified complex function argument z.</returns>
        public static ComplexFloat Tan(ComplexFloat z)
        {
            double sinzr = Math.Sin(z.Re);
            double coszr = Math.Cos(z.Re);
            double ezi   = Math.Exp(z.Im);
            double inv   = 1.0 / ezi;
            double ediff = inv - ezi;
            double esum  = inv + ezi;

            return(ComplexFloat.FromRealImaginary((float)(4 * sinzr * coszr), (float)(-ediff * esum)) / (float)(square(coszr * esum) + square(sinzr * ediff)));
        }