예제 #1
0
 public static Complex Modulus(this Complex num1, Complex num2)
 {
     if (!num1.IsReal())
         ErrorLog.Add(new ErrorMessage("Imaginary part ignored for first parameter"));
     if (!num2.IsReal())
         ErrorLog.Add(new ErrorMessage("Imaginary part ignored for second parameter"));
     return new Complex(num1.Real % num2.Real, 0);
 }
예제 #2
0
        public static Complex ArcSin(Complex value)
        {
            if (value.IsReal()) return Math.Asin(value.Real);

            if (value.IsImaginary() || value.Imaginary == 0d && value.Real < 0)
            {
                return -ArcSin(-value);
            }

            return -Complex.ImaginaryOne * Sqrt(Ln((1 - value.Square())) + (Complex.ImaginaryOne * value));
        }
예제 #3
0
        public static Complex ArcCos(Complex value)
        {
            if (value.IsReal()) return Math.Acos(value.Real);

            /*if (value.Imaginary < 0 || value.Imaginary == 0d && value.Real > 0)
			{
				return Constant.Pi - Acos(-value);
			}
			*/
            return -Complex.ImaginaryOne * Ln(value + Complex.ImaginaryOne * Sqrt(1 - value.Square()));

            //return (Constant.Pi / 2.0) + Constant.I * Ln(Constant.I * value + Sqrt(1 - value.Square()));
        }
예제 #4
0
 public static Complex Round(Complex a)
 {
     if (!a.IsReal()) return new Complex(Round(a.Real), Round(a.Imaginary), a.ViewMode, a.IsIndeterminate());
     return Abs(Frac(a)) < 0.5 ? Floor(a) : Ceil(a);
 }
예제 #5
0
 public static Complex Abs(Complex value)
 {
     return value.IsReal() ? Quad.Abs(value.Real) : value.Module;
 }
예제 #6
0
 public static Complex PolyLog(Complex v, Complex p, Complex z)
 {
     if (z.Module >= 1) return Complex.Indeterminate;
     if ((p.Real % 1) != 0) return Complex.Indeterminate;
     if (p <= 0) return Complex.Indeterminate;
     return p.IsReal() ? SumInf(k => (Pow(-1, k + p) * StirlingS1(k, p) * Pow(z, k)) / (Pow(k, v) * Fact(k)), 1) : Complex.Indeterminate;
 }
예제 #7
0
        public static Complex ArcTan(Complex value)
        {
            if (value.IsReal()) return Math.Atan(value.Real);

            var iz = new Complex(-value.Imaginary, value.Real);
            return new Complex(0, 0.5) * (Ln(1 - iz) - Ln(1 + iz));
        }
예제 #8
0
 public static Complex UnitStep(Complex x)
 {
     if (!x.IsReal()) return Complex.Indeterminate;
     if (x >= 0.0) return 1.0;
     if (x < 0.0) return 0.0;
     return Complex.Indeterminate;
 }
예제 #9
0
 public static Complex PrimePi(Complex x)
 {
     if (!x.IsReal()) return Complex.Indeterminate;
     if (x.Real < 0) return 0.0;
     return Sum(k => UnitStep(x - Prime(k)), 1, Floor(x));
 }