Exemple #1
0
        public static void Main()
        {
            double testOne = InfiniteSeries.Sum(1, 1, (x, y) => x / y, x => x, y => y * 2);

            Console.WriteLine(testOne);

            double testTwo = InfiniteSeries.Sum(1, 1, (x, y) => x / InfiniteSeries.Factorial(y), x => x, y => y + 1);

            Console.WriteLine(testTwo);

            double testThree = InfiniteSeries.Sum(2, 0, (x, y) => y % 2 == 0 && y != 0 ? -Math.Pow(x, y) : Math.Pow(x, y), x => x, y => y - 1);

            Console.WriteLine(testThree);
        }
        static void Main(string[] args)
        {
            InfiniteSeries first = FirstLine;

            Console.WriteLine(first(0.01));

            InfiniteSeries second = SecondLine;

            Console.WriteLine(second(0.01));

            InfiniteSeries third = ThirdLine;

            Console.WriteLine(third(0.001));
        }
Exemple #3
0
        public static void Main()
        {
            var firstTest  = InfiniteSeries.GetSum(1, 1, (x, y) => x / y, x => x, y => y * 2);
            var secondTest = InfiniteSeries.GetSum(1, 1, (x, y) => x / InfiniteSeries.Factorial(y), x => x, y => y + 1);
            var thirdTest  = InfiniteSeries.GetSum(1, 2, (x, y) => x / y, x => x, y => y * -2) + 1;

            // for 1 + 1/2 + 1/4 + 1/8 + 1/16 + …
            Console.WriteLine("{0:0.00}", firstTest);

            // for 1 + 1/2! + 1/3! + 1/4! + 1/5! + …
            Console.WriteLine("{0:0.00}", secondTest);

            // for 1 + 1/2 - 1/4 + 1/8 - 1/16 + …
            Console.WriteLine("{0:0.00}", thirdTest);
        }