Advertisement
Guest User

Untitled

a guest
Nov 24th, 2014
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.19 KB | None | 0 0
  1. using System;
  2.  
  3.  
  4. namespace ConsoleApplication1
  5. {
  6.     class Program
  7.     {
  8.         static void Main(string[] args)
  9.         {
  10.             Console.WriteLine("Вычисление функции y=sinx");
  11.             double x, y, a = 0.1, b = 1.0, k = 10, sn = 0, se = 0;
  12.             double step;
  13.             int n = 10;
  14.             step = (b - a) / k;
  15.             for (x = 0.1; x <= 1.0; x += step)
  16.             {
  17.                 y = Math.Sin(x);
  18.                 double ae = x;
  19.                 double an = x;
  20.                 sn = an;
  21.                 se = ae;
  22.                 for (int i = 1; i <= n; i++)
  23.                 {
  24.                     an = an * (-x * x / (2 * i * (2 * i + 1)));
  25.                     sn += an;
  26.                 }
  27.                 int j = 1;
  28.                 while (Math.Abs(ae) >= 0.0001)
  29.                 {
  30.                     ae = ae * (-x * x / (2 * j * (2 * j + 1)));
  31.                     se += ae;
  32.                     j++;
  33.                 }
  34.                 Console.WriteLine("X={0} SN={1} SE={2} Y={3}", x, sn, se, y);
  35.             }
  36.             Console.WriteLine("Нажмите любую клавишу...");
  37.             Console.ReadKey();
  38.         }
  39.     }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement