/// <summary> /// This function returns the complex hyperbolic arccosine of /// the real number a, arccosh(a). /// </summary> /// <param name="a">Function argument.</param> /// <returns>The complex hyperbolic arccosine of /// the real number a.</returns> public static Complex Acosh(double a) { Complex z; if (a >= 1) { z = new Complex(RMath.Acosh(a), 0); } else { if (a >= -1.0) { z = new Complex(0, Math.Acos(a)); } else { z = new Complex(RMath.Acosh(-a), M_PI); } } return(z); }
/// <summary> /// This function returns the complex arcsecant of the real number a, /// arcsec(a) = arccos(1/a). /// </summary> /// <param name="a">Function argument.</param> /// <returns>The complex arcsecant of the real number a.</returns> public static Complex Asec(double a) { Complex z; if (a <= -1.0 || a >= 1.0) { z = new Complex(Math.Acos(1 / a), 0.0); } else { if (a >= 0.0) { z = new Complex(0, RMath.Acosh(1 / a)); } else { z = new Complex(M_PI, -RMath.Acosh(-1 / a)); } } return(z); }
/// <summary> /// This function returns the complex arccosine of the real number a, arccos(a). /// </summary> /// <param name="a">The function argument.</param> /// <returns>The complex arccosine of the real number a.</returns> /// <remarks> /// For a between -1 and 1, the /// function returns a real value in the range [0,pi]. For a /// less than -1 the result has a real part of pi/2 and a /// negative imaginary part. For a greater than 1 the result /// is purely imaginary and positive. /// </remarks> public static Complex Acos(double a) { Complex z; if (Math.Abs(a) <= 1.0) { z = new Complex(Math.Acos(a), 0); } else { if (a < 0.0) { z = new Complex(Math.PI, -RMath.Acosh(-a)); } else { z = new Complex(0, RMath.Acosh(a)); } } return(z); }
//----------------------------------------------------------------------------------- //----------------------------------------------------------------------------------- /// <summary> /// The modulus (length) of the complex number /// </summary> /// <returns></returns> public double GetModulus() { return(RMath.Hypot(Re, Im)); }
/// <summary> /// This function returns the complex arcsine of the complex number a, /// arcsin(a)}. The branch cuts are on the real axis, less than -1 /// and greater than 1. /// </summary> /// <param name="a">The function argument.</param> /// <returns>the complex arcsine of the complex number a.</returns> public static Complex Asin(Complex a) { double R = a.Re, I = a.Im; Complex z; if (I == 0) { z = Asin(R); } else { double x = Math.Abs(R), y = Math.Abs(I); double r = hypot(x + 1, y), s = hypot(x - 1, y); double A = 0.5 * (r + s); double B = x / A; double y2 = y * y; double real, imag; const double A_crossover = 1.5, B_crossover = 0.6417; if (B <= B_crossover) { real = Math.Asin(B); } else { if (x <= 1) { double D = 0.5 * (A + x) * (y2 / (r + x + 1) + (s + (1 - x))); real = Math.Atan(x / Math.Sqrt(D)); } else { double Apx = A + x; double D = 0.5 * (Apx / (r + x + 1) + Apx / (s + (x - 1))); real = Math.Atan(x / (y * Math.Sqrt(D))); } } if (A <= A_crossover) { double Am1; if (x < 1) { Am1 = 0.5 * (y2 / (r + (x + 1)) + y2 / (s + (1 - x))); } else { Am1 = 0.5 * (y2 / (r + (x + 1)) + (s + (x - 1))); } imag = RMath.Log1p(Am1 + Math.Sqrt(Am1 * (A + 1))); } else { imag = Math.Log(A + Math.Sqrt(A * A - 1)); } z = new Complex((R >= 0) ? real : -real, (I >= 0) ? imag : -imag); } return(z); }