Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace ConsoleApplication1
- {
- class Program
- {
- static void Main(string[] args)
- {
- Console.WriteLine("Вычисление функции y=sinx");
- double x, y, a = 0.1, b = 1.0, k = 10, sn = 0, se = 0;
- double step;
- int n = 10;
- step = (b - a) / k;
- for (x = 0.1; x <= 1.0; x += step)
- {
- y = Math.Sin(x);
- double ae = x;
- double an = x;
- sn = an;
- se = ae;
- for (int i = 1; i <= n; i++)
- {
- an = an * (-x * x / (2 * i * (2 * i + 1)));
- sn += an;
- }
- int j = 1;
- while (Math.Abs(ae) >= 0.0001)
- {
- ae = ae * (-x * x / (2 * j * (2 * j + 1)));
- se += ae;
- j++;
- }
- Console.WriteLine("X={0} SN={1} SE={2} Y={3}", x, sn, se, y);
- }
- Console.WriteLine("Нажмите любую клавишу...");
- Console.ReadKey();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement