public void ComplexLogExp() { foreach (Complex z in TestUtilities.GenerateComplexValues(1.0E-4, 1.0E4, 16)) { Assert.IsTrue(TestUtilities.IsNearlyEqual(ComplexMath.Exp(ComplexMath.Log(z)), z)); } }
public void ComplexExpReflection() { foreach (Complex z in TestUtilities.GenerateComplexValues(1.0E-2, 1.0E2, 8)) { Assert.IsTrue(TestUtilities.IsNearlyEqual(ComplexMath.Exp(-z), 1.0 / ComplexMath.Exp(z))); } }
public void ComplexDiLogClausen() { foreach (double t in TestUtilities.GenerateUniformRealValues(0.0, 2.0 * Math.PI, 4)) { Complex z = AdvancedComplexMath.DiLog(ComplexMath.Exp(ComplexMath.I * t)); Assert.IsTrue(TestUtilities.IsNearlyEqual(z.Re, Math.PI * Math.PI / 6.0 - t * (2.0 * Math.PI - t) / 4.0)); Assert.IsTrue(TestUtilities.IsNearlyEqual(z.Im, AdvancedMath.Clausen(t))); } }
public void ComplexLogGammaComplexGammaAgreement() { foreach (Complex z in TestUtilities.GenerateComplexValues(1.0E-2, 1.0E2, 16)) { Assert.IsTrue(TestUtilities.IsNearlyEqual( ComplexMath.Exp(AdvancedComplexMath.LogGamma(z)), AdvancedComplexMath.Gamma(z) )); } }
private IntegrationResult RambleIntegral(int d, int s, IntegrationSettings settings) { return(MultiFunctionMath.Integrate((IReadOnlyList <double> x) => { Complex z = 0.0; for (int k = 0; k < d; k++) { z += ComplexMath.Exp(2.0 * Math.PI * Complex.I * x[k]); } return (MoreMath.Pow(ComplexMath.Abs(z), s)); }, UnitCube(d), settings)); }
public void ComplexRealAgreement() { foreach (double x in TestUtilities.GenerateRealValues(0.01, 1000.0, 8)) { Assert.IsTrue(ComplexMath.Exp(x) == Math.Exp(x)); Assert.IsTrue(ComplexMath.Log(x) == Math.Log(x)); Assert.IsTrue(ComplexMath.Sqrt(x) == Math.Sqrt(x)); Assert.IsTrue(ComplexMath.Abs(x) == Math.Abs(x)); Assert.IsTrue(ComplexMath.Arg(x) == 0.0); } }
public void ComplexErfFaddevaAgreement () { foreach (Complex z in TestUtilities.GenerateComplexValues(1.0E-1, 1.0E2, 16)) { Complex w = AdvancedComplexMath.Faddeeva(z); Complex erf = AdvancedComplexMath.Erf(-ComplexMath.I * z); Complex erfc = 1.0 - erf; Complex f = ComplexMath.Exp(z * z); Console.WriteLine("z={0} w={1} erf={2} erfc={3} f={4} w'={5} erf'={6}", z, w, erf, erfc, f, erfc / f, 1.0 - f * w); if (Double.IsInfinity(f.Re) || Double.IsInfinity(f.Im) || f == 0.0) continue; //Console.WriteLine("{0} {1}", TestUtilities.IsNearlyEqual(w, erfc / f), TestUtilities.IsNearlyEqual(erf, 1.0 - f * w)); Assert.IsTrue(TestUtilities.IsNearlyEqual( erf, 1.0 - f * w )); } }
public void ComplexExpSumTest() { foreach (Complex x in TestUtilities.GenerateComplexValues(1.0E-2, 1.0E2, 6)) { foreach (Complex y in TestUtilities.GenerateComplexValues(1.0E-2, 1.0E2, 6)) { // don't overflow exp if ((Math.Abs(x.Re) + Math.Abs(y.Re)) > Math.Log(Double.MaxValue / 10.0)) { continue; } Console.WriteLine("x,y = {0},{1}", x, y); Complex ex = ComplexMath.Exp(x); Complex ey = ComplexMath.Exp(y); Complex xy = x + y; Complex exy = ComplexMath.Exp(xy); // if components of x and y differ by orders of magnitude, // trailing digits will be lost in (x+y), thus changing e^(x+y) // but they will not be lost in e^x and e^y, so agreement will fail due to rounding error // thus we should reduce expected agreement by this ratio double rr = Math.Abs(Math.Log(Math.Abs(x.Re / y.Re))); double ri = Math.Abs(Math.Log(Math.Abs(x.Im / y.Im))); double r = rr; if (ri > r) { r = ri; } //if (r < 0.0) r = 0.0; double e = TestUtilities.TargetPrecision * Math.Exp(r); Console.WriteLine("e={0}", e); Assert.IsTrue(TestUtilities.IsNearlyEqual(exy, ex * ey, e), String.Format("x={0} y={1} E(x)={2} E(y)={3} E(x)*E(y)={4} E(x+y)={5}", x, y, ex, ey, ex * ey, exy)); } } }
public void ComplexPowExponent() { foreach (Complex z in TestUtilities.GenerateComplexValues(1.0E-2, 1.0E2, 6)) { Assert.IsTrue(TestUtilities.IsNearlyEqual(ComplexMath.Pow(Math.E, z), ComplexMath.Exp(z))); } }
public void ComplexExpExtremeValues() { Assert.IsTrue(ComplexMath.Exp(Double.NegativeInfinity) == Complex.Zero); Assert.IsTrue(Complex.IsNaN(ComplexMath.Exp(Double.NaN))); }
public void ComplexExpSpecialValues() { Assert.IsTrue(ComplexMath.Exp(0.0) == Complex.One); Assert.IsTrue(ComplexMath.Exp(1.0) == Math.E); Assert.IsTrue(TestUtilities.IsNearlyEqual(ComplexMath.Exp(Complex.I * Math.PI), -Complex.One)); }
public void ComplexExpSpecialCase() { Assert.IsTrue(ComplexMath.Exp(0.0) == 1.0); Assert.IsTrue(ComplexMath.Exp(1.0) == Math.E); }