Advertisement
Guest User

Untitled

a guest
Oct 21st, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.88 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace LAB_3_CH
  8. {
  9. class Задание
  10. {
  11. static void Main(string[] args)
  12. {
  13. int n = 15;
  14. double a = 0.1, b = 1, k = 10;
  15. double periodx = ((b - a) / k);
  16. double e = 0.0001;
  17. double x = 0.1;
  18. Console.WriteLine("0,1 <= x <= 1 n = 15");
  19. Console.WriteLine(" ");
  20. while(x <= b)
  21. {
  22. double sn = (Math.Pow(-1, 1) * (Math.Pow((2 * x), 2))) / 2,
  23. res = 1,
  24. se = (Math.Pow(-1, 1) * (Math.Pow((2 * x), 2))) / 2;
  25. double y = 2 * (Math.Pow(Math.Cos(x), 2) - 1);
  26. for (int period1 = 1; period1 <= n; period1++)
  27. {
  28. int fact = 1;
  29. for (int i = 1; i <= period1; i++)
  30. {
  31. fact *= i;
  32. }
  33. res = (Math.Pow(-1, period1)*(Math.Pow((2 * x), (2 * period1)))) / (2 * fact);
  34. sn += res;
  35.  
  36. }
  37. int period2 = 1;
  38. do
  39. {
  40. int fact = 1;
  41. for (int i = 1; i <= period2; i++)
  42. {
  43. fact *= i;
  44. }
  45. res = (Math.Pow(-1, period2) * (Math.Pow((2 * x), (2 * period2)))) / (2 * fact);
  46.  
  47. se += res;
  48. period2++;
  49. }
  50. while (res >= e);
  51. Console.WriteLine("X={0:000000000000} SN={1:00000} SE={2:00000} Y={3:00000}", x, sn, se, y);
  52. x += periodx;
  53. }
  54. Console.ReadKey();
  55. }
  56. }
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement