t440.py 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. import math
  2. def isCloseTo(expected, actual, precision):
  3. return math.fabs(expected - actual) < (math.pow(10, -precision) / 2)
  4. print "\nmath.acos(x)"
  5. print math.acos(1.0)
  6. print math.acos(0.5)
  7. print math.acos(0.0)
  8. print math.acos(-0.5)
  9. print math.acos(-1.0)
  10. print math.acos(-1)
  11. print "\nmath.asin(x)"
  12. print math.asin(1.0)
  13. print math.asin(0.5)
  14. print math.asin(0.0)
  15. print math.asin(-0.5)
  16. print math.asin(-1.0)
  17. print math.asin(-1)
  18. print "\nmath.atan(x)"
  19. print math.atan(1.0)
  20. print math.atan(0.5)
  21. print math.atan(0.0)
  22. print math.atan(-0.5)
  23. print math.atan(-1.0)
  24. print math.atan(-1)
  25. print "\nmath.atan2(y,x)"
  26. print math.atan2(1,1)
  27. print math.atan2(1,-1)
  28. print math.atan2(-1,1)
  29. print math.atan2(-1,-1)
  30. print math.atan2(-5.1,6.3)
  31. print "\nmath.cos(x)"
  32. print math.cos(0.0)
  33. print isCloseTo(0, math.cos(math.pi/2.0), 15)
  34. print math.cos(math.pi)
  35. print math.cos(1)
  36. print "\nmath.sin(x)"
  37. print math.sin(0.0)
  38. print math.sin(math.pi/2.0)
  39. print isCloseTo(0, math.sin(math.pi), 15)
  40. print math.sin(1)
  41. print "\nmath.tan(x)"
  42. print math.tan(0.0)
  43. print isCloseTo(0, math.tan(math.pi), 15)
  44. print math.tan(1)
  45. print "\nmath.degrees(x)"
  46. print math.degrees(0.0)
  47. print math.degrees(0.261799387799)
  48. print math.degrees(0.785398163397)
  49. print math.degrees(1.57079632679)
  50. print math.degrees(3.14159265359)
  51. print math.degrees(4.71238898038)
  52. print math.degrees(6.28318530718)
  53. print math.degrees(0)
  54. print "\nmath.radians(x)"
  55. print math.radians(0)
  56. print math.radians(15)
  57. print math.radians(45)
  58. print math.radians(90)
  59. print math.radians(180)
  60. print math.radians(270)
  61. print math.radians(360)