Advertisement
Guest User

Untitled

a guest
Oct 28th, 2016
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1. static void YL14()
  2. {
  3. int algus = -90, lõpp = 90, samm = 10;
  4. //int algus = 270, lõpp = 450, samm = 10;
  5. double f1, f2, f3;
  6. for (int g = algus; g <= lõpp; g += samm)
  7. {
  8. double r = Math.PI * g / 180;
  9. f1 = Math.Cos(r);
  10. f2 = CosF(r, 5);
  11. f3 = CosF2(r, 5);
  12. Console.WriteLine("{0:N1} {1,9:N5} {2,9:N5} {3,9:N5}", g, f1, f2, f3);
  13. }
  14. }
  15.  
  16. static double CosF(double x, int t) // x-nurk t-täpsus
  17. {
  18. double Summa = 0;
  19. int n = 0;
  20. double An;
  21. do
  22. {
  23. An = AsteF(-1, n) * AsteF(x, 2 * n) / FactF(2 * n);
  24. Summa += An;
  25. n++;
  26. } while (Math.Abs(An) > Math.Pow(10, -t) && n < 1000);
  27. return Summa;
  28. }
  29.  
  30. static double CosF2(double x, int t) // x-nurk t-täpsus
  31. {
  32. int n = 0;
  33. double An = 1;
  34. double Summa = An;
  35. do
  36. {
  37. n++;
  38. double suhe = -x * x / (2 * n * (2 * n - 1));
  39. An = An * suhe;
  40. Summa += An;
  41. } while (Math.Abs(An) > Math.Pow(10, -t) && n < 1000);
  42. return Summa;
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement