public static __ct__[] Csqrt(this __ct__ number) { __ct__ res0 = __ct__.CreateRadial(Sqrt(number.Norm), number.Argument / 2); __ct__ res1 = __ct__.CreateRadial(Sqrt(number.Norm), number.Argument / 2 + (__ft__)Constant.Pi); return(new __ct__[2] { res0, res1 }); }
public static __ct__ Power(this __ct__ number, __ft__ exponent) { if (number.IsZero) { return(__ct__.Zero); } else { __ft__ r = number.Norm; __ft__ phi = number.Argument; return(__ct__.CreateRadial(Pow(r, exponent), exponent * phi)); } }
public static __ct__ Tan(this __ct__ x) { if (x == __ct__.PositiveInfinityI) { return(__ct__.I); } else if (x == __ct__.NegativeInfinityI) { return(-__ct__.I); } else { return(Sin(x) / Cos(x)); } }
public static __ct__[] Root(this __ct__ number, int n) { __ct__[] values = new __ct__[n]; __ft__ invN = 1 / (__ft__)n; __ft__ phi = number.Argument / n; __ft__ dphi = __cast__Constant.PiTimesTwo * invN; __ft__ r = Pow(number.Norm, invN); for (int i = 0; i < n; i++) { values[i] = __ct__.CreateRadial(r, phi + dphi * i); } return(values); }
public static __ct__ Sqrt(this __ct__ x) { if (x.Imag == 0) { if (x.Real < 0) { return(new __ct__(0, Sqrt(-x.Real))); } else { return(new __ct__(Sqrt(x.Real), 0)); } } else { var a = x.Norm; var b = x + a; return(a.Sqrt() * (b / b.Norm)); } }
public static __ct__ Power(this __ct__ number, __ct__ exponent) { if (number.IsZero) { return(__ct__.Zero); } else if (exponent.IsZero) { return(__ct__.One); } else { __ft__ r = number.Norm; __ft__ phi = number.Argument; __ft__ a = exponent.Real; __ft__ b = exponent.Imag; return(__ct__.CreateRadial(Exp(Log(r) * a - b * phi), a * phi + b * Log(r))); } }
public static __ct__ Power(this __ft__ number, __ct__ exponent) { if (number == 0) { return(__ct__.Zero); } else { __ft__ a = exponent.Real; __ft__ b = exponent.Imag; if (number < 0) { var phi = __cast__Constant.Pi; return(__ct__.CreateRadial(Exp(Log(-number) * a - b * phi), a * phi + b * Log(-number))); } else { return(__ct__.CreateRadial(Pow(number, a), b * Log(number))); } } }
public static __ct__ Atanh(this __ct__ x) { if (x == __ct__.Zero) { return(__ct__.Zero); } else if (x == __ct__.One) { return(__ct__.PositiveInfinity); } else if (x == __ct__.PositiveInfinity) { return(new __ct__(0, -__cast__Constant.PiHalf)); } else if (x == __ct__.I) { return(new __ct__(0, __cast__Constant.PiQuarter)); } else { return(__half__ * (Log(1 + x) - Log(1 - x))); } }
public static __ct__ Atan(this __ct__ x) { if (x == __ct__.I) { return(__ct__.PositiveInfinityI); } else if (x == -__ct__.I) { return(__ct__.NegativeInfinityI); } else if (x == __ct__.PositiveInfinity) { return(new __ct__(__cast__Constant.PiHalf)); } else if (x == __ct__.NegativeInfinity) { return(new __ct__(-__cast__Constant.PiHalf)); } else { return(new __ct__(0, __half__) * Log((__ct__.I + x) / (__ct__.I - x))); } }
public static __ct__ Acosh(this __ct__ x) => Log(x + Sqrt(x * x - 1));
public static __ct__ Sinh(this __ct__ x) { var sin = Sin(new __ct__(-x.Imag, x.Real)); return(new __ct__(sin.Imag, -sin.Real)); }
public static __ct__ Conjugated(__ct__ c) => c.Conjugated;
public static __ft__ NormSquared(__ct__ c) => c.NormSquared;
public static __ct__ Log10(this __ct__ x) => Log(x, 10);
public static __ct__ Log(this __ct__ x) => new __ct__(Log(x.Norm), x.Argument);
public static __ct__ Tanh(this __ct__ x) { var tan = Tan(new __ct__(-x.Imag, x.Real)); return(new __ct__(tan.Imag, -tan.Real)); }
public static __ct__ Acos(this __ct__ x) { var t = Log(new __ct__(-x.Imag, x.Real) + Sqrt(1 - x * x)); return(new __ct__(-t.Imag + __cast__Constant.PiHalf, t.Real)); }
public static __ct__ Pow(this __ft__ number, __ct__ exponent) => Power(number, exponent);
public static __ft__ Norm(__ct__ c) => c.Norm;
public static __ft__ Argument(__ct__ c) => c.Argument;
public static __ct__ Exp(this __ct__ x) => new __ct__(Cos(x.Imag), Sin(x.Imag)) * Exp(x.Real);
public static __ct__ Cos(this __ct__ x) => ( Exp(new __ct__(-x.Imag, x.Real)) + Exp(new __ct__(x.Imag, -x.Real)) ) * __half__;
public static __ct__ Log(this __ct__ x, __ft__ basis) => x.Log() / basis.Log();
public static __ct__ Cosh(this __ct__ x) => Cos(new __ct__(-x.Imag, x.Real));
public static __ct__ Log2(this __ct__ x) => x.Log() * __cast__Constant.Ln2Inv;
public static __ct__ Asin(this __ct__ x) { var t = Log(new __ct__(-x.Imag, x.Real) + Sqrt(1 - x * x)); return(new __ct__(t.Imag, -t.Real)); }
public static __ct__ Cbrt(this __ct__ x) => __ct__.CreateRadial(Cbrt(x.Norm), x.Argument / 3);
public static __ct__ Asinh(this __ct__ x) => Log(x + Sqrt(1 + x * x));
public static __ct__ Sin(this __ct__ x) { var a = Exp(new __ct__(-x.Imag, x.Real)) - Exp(new __ct__(x.Imag, -x.Real)); return(new __ct__(a.Imag, -a.Real) * __half__); }
public static bool IsFinite(this __ct__ v) => !(v.IsNaN || v.IsInfinity);