public void GammaBorderTest()
        {
            MultiPrecision <Pow2.N8>[] borders = new MultiPrecision <Pow2.N8>[] { 0.5, 1 };

            foreach (MultiPrecision <Pow2.N8> b in borders)
            {
                List <MultiPrecision <Pow2.N8> > ys = new();

                foreach (MultiPrecision <Pow2.N8> x in TestTool.EnumerateNeighbor(b))
                {
                    MultiPrecision <Pow2.N8> y = MultiPrecision <Pow2.N8> .Gamma(x);

                    Console.WriteLine(x);
                    Console.WriteLine(x.ToHexcode());
                    Console.WriteLine(y);
                    Console.WriteLine(y.ToHexcode());
                    Console.Write("\n");

                    TestTool.Tolerance(Approx.Gamma((double)x), y, ignore_sign: true);

                    ys.Add(y);
                }

                TestTool.NearlyNeighbors(ys, 2);
                TestTool.SmoothnessSatisfied(ys, 1);
                TestTool.MonotonicitySatisfied(ys);

                Console.Write("\n");
            }
        }
        public void GammaApproxTest()
        {
            Assert.AreEqual(1, Approx.Gamma(1), 1e-10);
            Assert.AreEqual(1, Approx.Gamma(2), 1e-10);
            Assert.AreEqual(2, Approx.Gamma(3), 1e-10);
            Assert.AreEqual(6, Approx.Gamma(4), 1e-10);
            Assert.AreEqual(24, Approx.Gamma(5), 1e-10);

            Assert.AreEqual(Math.Sqrt(Math.PI) * 4 / 3, Approx.Gamma(-1.5), 1e-10);
            Assert.AreEqual(Math.Sqrt(Math.PI) * -2, Approx.Gamma(-0.5), 1e-10);
            Assert.AreEqual(Math.Sqrt(Math.PI), Approx.Gamma(0.5), 1e-10);
            Assert.AreEqual(Math.Sqrt(Math.PI) / 2, Approx.Gamma(1.5), 1e-10);
            Assert.AreEqual(Math.Sqrt(Math.PI) * 3 / 4, Approx.Gamma(2.5), 1e-10);
            Assert.AreEqual(Math.Sqrt(Math.PI) * 15 / 8, Approx.Gamma(3.5), 1e-10);
        }
        public void GammaTest()
        {
            for (int i = -200; i < 200; i++)
            {
                if (i <= 0 && i % 4 == 0)
                {
                    continue;
                }

                MultiPrecision <Pow2.N8> x = MultiPrecision <Pow2.N8> .Ldexp(MultiPrecision <Pow2.N8> .One, -2) * i;

                MultiPrecision <Pow2.N8> y = MultiPrecision <Pow2.N8> .Gamma(x);

                Console.WriteLine(x);
                Console.WriteLine(y);

                TestTool.Tolerance(Approx.Gamma((double)x), y, rateerr: 1e-10, ignore_sign: true);
            }

            Assert.IsTrue(1 == MultiPrecision <Pow2.N8> .Gamma(1));
            Assert.IsTrue(1 == MultiPrecision <Pow2.N8> .Gamma(2));
            Assert.IsTrue(2 == MultiPrecision <Pow2.N8> .Gamma(3));
            Assert.IsTrue(6 == MultiPrecision <Pow2.N8> .Gamma(4));
            Assert.IsTrue(24 == MultiPrecision <Pow2.N8> .Gamma(5));

            Assert.IsTrue(
                MultiPrecision <Pow2.N8> .NearlyEqualBits(
                    MultiPrecision <Pow2.N8> .Sqrt(MultiPrecision <Pow2.N8> .PI) * 4 / 3,
                    MultiPrecision <Pow2.N8> .Gamma(-1.5),
                    2
                    ));

            Assert.IsTrue(
                MultiPrecision <Pow2.N8> .NearlyEqualBits(
                    MultiPrecision <Pow2.N8> .Sqrt(MultiPrecision <Pow2.N8> .PI) * -2,
                    MultiPrecision <Pow2.N8> .Gamma(-0.5),
                    2
                    ));

            Assert.IsTrue(
                MultiPrecision <Pow2.N8> .NearlyEqualBits(
                    MultiPrecision <Pow2.N8> .Sqrt(MultiPrecision <Pow2.N8> .PI),
                    MultiPrecision <Pow2.N8> .Gamma(0.5),
                    2
                    ));

            Assert.IsTrue(
                MultiPrecision <Pow2.N8> .NearlyEqualBits(
                    MultiPrecision <Pow2.N8> .Sqrt(MultiPrecision <Pow2.N8> .PI) / 2,
                    MultiPrecision <Pow2.N8> .Gamma(1.5),
                    2
                    ));

            Assert.IsTrue(
                MultiPrecision <Pow2.N8> .NearlyEqualBits(
                    MultiPrecision <Pow2.N8> .Sqrt(MultiPrecision <Pow2.N8> .PI) * 3 / 4,
                    MultiPrecision <Pow2.N8> .Gamma(2.5),
                    2
                    ));

            Assert.IsTrue(
                MultiPrecision <Pow2.N8> .NearlyEqualBits(
                    MultiPrecision <Pow2.N8> .Sqrt(MultiPrecision <Pow2.N8> .PI) * 15 / 8,
                    MultiPrecision <Pow2.N8> .Gamma(3.5),
                    2
                    ));
        }