Advertisement
Guest User

Untitled

a guest
Nov 24th, 2014
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.21 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, sn, se;
  12.             double step;
  13.             int n = 10;
  14.             step = (1.0 - 0.1) / 10;
  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.                     Console.WriteLine(an);
  26.                     sn += an;
  27.                 }
  28.                 int j = 1;
  29.                 while (Math.Abs(y-ae) >= 0.0001)
  30.                 {
  31.                     ae = ae * (-x * x / (2 * j * (2 * j + 1)));
  32.                     se += ae;
  33.                     j++;
  34.                 }
  35.                 Console.WriteLine("X={0} SN={1} SE={2} Y={3}", x, sn, se, y);
  36.             }
  37.             Console.WriteLine("Нажмите любую клавишу...");
  38.             Console.ReadKey();
  39.         }
  40.     }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement