Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- public class Program
- {
- public static void Main()
- {
- Console.WriteLine("Введите X: ");
- double x = Convert.ToDouble(Console.ReadLine());
- Console.WriteLine("Введите K: ");
- double k = Convert.ToDouble(Console.ReadLine());
- Console.WriteLine("Введите EPS: ");
- double EPS = Convert.ToDouble(Console.ReadLine());
- if (Math.Abs(x) > 1)
- {
- Console.WriteLine("Неверное значение аргумента");
- return;
- }
- double s = 0;
- double last = 0;
- for (int i = 0; ; i++)
- {
- double cur = (f(2 * i) * Math.Pow(x, 2 * i + 1)) / ((Math.Pow(4, i) * Math.Pow(f(i), 2) * (2 * i + 1)));
- if (Math.Abs(cur - last) < EPS) break;
- s += cur;
- last = cur;
- }
- Console.WriteLine("f1()");
- Console.WriteLine(Math.PI / 2 - s);
- s = 0;
- last = 0;
- for (int i = 0;i<=k ; i++)
- {
- double cur = (f(2 * i) * Math.Pow(x, 2 * i + 1)) / ((Math.Pow(4, i) * Math.Pow(f(i), 2) * (2 * i + 1)));
- s += cur;
- last = cur;
- }
- Console.WriteLine("f2()");
- Console.WriteLine(Math.PI/2 - s);
- Console.WriteLine("f()");
- Console.WriteLine(Math.Acos(x));
- Console.ReadKey();
- }
- //факториал
- static double f(int x)
- {
- return (x == 0) ? 1 : x * f(x - 1);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement