Assert.That(ExactSizeRefusal("9^9^9"),Is.EqualTo("'9 ^ 9 ^ 9' would have about 369,693,100 digits as an exact number; its decimal logarithm is about 369693099.632. The tool computes such a number in full and cannot stop midway, so exact numbers are limited to 20,000 digits."));
Assert.That(ExactSizeRefusal("9^9^9^9"),Does.StartWith("'9 ^ 9 ^ 9' would have"),"The inner power is judged first, before its value is needed.");
Assert.That(ExactSizeRefusal("1 + 10^20001"),Does.StartWith("'10 ^ 20001' would have about 20,001 digits"));
Assert.That(ExactSizeRefusal("(1/2)^100000"),Does.Contain("would have about 30,103 digits"),"Numerator and denominator count.");
Assert.That(ExactSizeRefusal("sqrt(2)^1000000"),Does.Contain("would have about"),"sqrt(2)^1000000 is the exact number 2^500000.");
Assert.That(ExactSizeRefusal("x^(9^9^9)"),Does.StartWith("'9 ^ 9 ^ 9' would have"),"An exponent is a number even when the base is a variable.");
Assert.That(ExactSizeRefusal("(e^0 + 1)^(10^9)"),Does.Contain("would have about 301,029,996 digits"),"A constant is no variable: the base is the number 2.");
}
}
[Test]
publicvoidRefusesAFactorialWithTooManyDigits()
{
using(Assert.EnterMultipleScope())
{
Assert.That(ExactSizeRefusal("(10^9)!"),Does.StartWith("'(10 ^ 9)!' would have about 8,565,705,"));
Assert.That(ExactSizeRefusal("10000!"),Does.StartWith("'10000!' would have about 35,660 digits"));
Assert.That(ExactSizeRefusal("(10!)!"),Does.StartWith("'(10!)!' would have about"));
Assert.That(ExactSizeRefusal("polygamma(101, 2)"),Is.EqualTo("'polygamma(101, 2)' has the order 101. The tool cannot stop the computation of polygamma midway, and its time grows with the order, so the order is limited to 100."));
Assert.That(ExactSizeRefusal("1 + polygamma(10^3, x)"),Does.StartWith("'polygamma(10 ^ 3, x)' has the order 1000."),"The order is a number even when the argument is a variable.");
Assert.That(ExactSizeRefusal("polygamma((10^9)!, 2)"),Does.StartWith("'(10 ^ 9)!' would have about"),"The order is judged before its value is needed.");
Assert.That(ExactSizeRefusal("gamma(1/2, 1001)"),Is.EqualTo("'gamma(1 / 2, 1001)' takes gamma(a, z) at a z of about 1001 in absolute value. The tool cannot stop this computation midway, and its time grows with z, so the absolute value of z is limited to 1,000."));
Assert.That(ExactSizeRefusal("gamma(1/2, 10 + 1000*i)"),Does.Contain("at a z of about 1000.05 in absolute value"));
Assert.That(ExactSizeRefusal("gamma(401/2, 2)"),Is.EqualTo("'gamma(401 / 2, 2)' takes gamma(a, z) for a = 401/2. The tool cannot stop this computation midway, and its time grows with z, the more so when a is negative or not real, so a is limited to the real numbers from -20 to 200."));
Assert.That(ExactSizeRefusal("gamma(-41/2, 2)"),Does.Contain("for a = -41/2."));
Assert.That(ExactSizeRefusal("gamma(1 + i, x)"),Does.Contain("for a = 1 + i."),"The parameter is a number even when z is a variable.");
// (10^6 * x)! and x^100000 at x = 0.61, as at a sample point of the checks:
Assert.That(Assert.Throws<MathComputationException>(()=>MathGuards.CheckValueAtPoint(Read("1 + (10^6 * 61/100)!")))!.Message,Does.StartWith("'(10 ^ 6 * 61 / 100)!' would have about 3,"));
Assert.That(Assert.Throws<MathComputationException>(()=>MathGuards.CheckValueAtPoint(Read("(61/100)^100000")))!.Message,Does.StartWith("'(61 / 100) ^ 100000' would have about 378,"));
Assert.That(refusal.Message,Is.EqualTo("'(x + y) ^ 500' raises a sum to the power of 500. Where the tool may expand, a sum is raised to exponents up to 200 only, since it cannot stop a larger expansion midway."));