public void ComplexFaddeevaDawson () { foreach (double x in TestUtilities.GenerateRealValues(1.0E-4,1.0E4,10)) { Complex w = AdvancedComplexMath.Faddeeva(x); double F = AdvancedMath.Dawson(x); Console.WriteLine("x={0} F={1} w={2}", x, F, w); Assert.IsTrue(TestUtilities.IsNearlyEqual(w.Re, Math.Exp(-x * x))); Assert.IsTrue(TestUtilities.IsNearlyEqual(w.Im, (2.0/Math.Sqrt(Math.PI)) * AdvancedMath.Dawson(x))); } }
public void OdeDawson() { // The Dawson function fulfills a simple ODE. // \frac{dF}{dx} + 2 x F = 1 \qquad F(0) = 0 // See e.g. https://en.wikipedia.org/wiki/Dawson_function // Verify that we get correct values via ODE integration. Func <double, double, double> rhs = (double x, double F) => 1.0 - 2.0 * x * F; foreach (double x1 in TestUtilities.GenerateRealValues(0.1, 10.0, 8)) { EvaluationSettings s = new EvaluationSettings() { RelativePrecision = 1.0E-13, AbsolutePrecision = 0.0 }; OdeResult r = FunctionMath.IntegrateOde(rhs, 0.0, 0.0, x1); Debug.WriteLine("{0}: {1} {2}: {3}", x1, r.Y, AdvancedMath.Dawson(x1), r.EvaluationCount); Assert.IsTrue(TestUtilities.IsNearlyEqual(r.Y, AdvancedMath.Dawson(x1), s)); } }