Ejemplo n.º 1
0
        public void TestExp(double x)
        {
            var         exp    = Math.Exp(x);
            BigRational upper  = exp.Increment();
            BigRational lower  = exp.Decrement();
            BigRational actual = SeriesExpansions.Exp(x, 500);

            Assert.True(actual < upper);
            Assert.True(actual > lower);
        }
Ejemplo n.º 2
0
        public void TestExpansion(int numerator, int denominator)
        {
            var power = new BigRational(numerator, denominator);

            Assert.AreEqual(
                BigRational.Zero,
                SeriesExpansions.Exp(power, 0));
            Assert.AreEqual(
                BigRational.One,
                SeriesExpansions.Exp(power, 1));
            Assert.AreEqual(
                1 + power,
                SeriesExpansions.Exp(power, 2));
            Assert.AreEqual(
                1 + power,
                SeriesExpansions.Exp(power, 2));
            Assert.AreEqual(
                1 + power + ((power * power) / 2),
                SeriesExpansions.Exp(power, 3));
            Assert.AreEqual(
                1 + power + ((power * power) / 2) + ((power * power * power) / 6),
                SeriesExpansions.Exp(power, 4));
        }