mathlib.tst 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. %. MATHLIB.TST
  2. % A simple set of tests for MAthLIB
  3. LOAD MATHLIB$
  4. Global '(EPS);
  5. EPS:=1.0/(1.0E6);
  6. Fexpr procedure TS L$ % (Function,Arg,Expected Value)
  7. Begin scalar Fn,Arg,Val,x,y;
  8. Fn:=car L$
  9. Arg:=EVAL cadr L$
  10. Val:=EVAL Caddr L$
  11. x:=Apply(fn, list arg)$
  12. PrintF(" %r(%p) = %p, expect %p%n",Fn,arg,x,val)$
  13. y:=abs(x-val);
  14. if y>=EPS then PrintF(" ***** %p exceeds EPS%n",y);
  15. End$
  16. TS(Ceiling,3,3);
  17. TS(Ceiling,3.1,4);
  18. TS(Ceiling,3.7,4);
  19. TS(Ceiling,-3,-3);
  20. TS(Ceiling,-3.5,-2);
  21. TS(Round,3,3);
  22. TS(Round,3.1,3);
  23. TS(Round,3.5,4);
  24. TS(Round,3.7,4);
  25. TS(Round,-3,-3);
  26. TS(Round,-3.4,-2);
  27. TS(Round,-3.7,-3);
  28. TwoPI := 6.2831853;
  29. PI:=TwoPI/2;
  30. PI2:=PI/2;
  31. PI4:=PI/4;
  32. PI8:=PI/8;
  33. Root2:=1.4142136;
  34. Root2**2 - 2.0;
  35. TS(sin, 0.0, 0.0)$
  36. TS(cos, 0.0, 1.0)$
  37. TS(sin, PI4, Root2/2)$
  38. TS(cos, PI4, Root2/2)$
  39. TS(sin, PI2, 1.0)$
  40. TS(cos, PI2, 0.0)$
  41. TS(sin, 3*PI4, Root2/2)$
  42. TS(cos, 3*PI4, -Root2/2)$
  43. TS(sin, PI, 0.0)$
  44. TS(cos, PI, -1.0)$
  45. procedure SC2 x;
  46. sin(x)**2+cos(x)**2;
  47. TS(SC2,0.0,1)$
  48. TS(SC2,0.25,1)$
  49. TS(SC2,0.5,1)$
  50. TS(SC2,0.75,1)$
  51. TS(SC2,1.0,1)$
  52. TS(SC2,1.25,1)$
  53. TS(SC2,1.5,1)$
  54. TS(SC2,1.75,1)$
  55. TS(SC2,2.0,1)$
  56. TS(SC2,2.25,1)$
  57. TS(SC2,2.5,1)$
  58. TS(SC2,2.75,1)$
  59. TS(SC2,3.0,1)$
  60. TS(TAN,0.0,0.0)$
  61. TS(TAN,PI8,SIN(PI8)/COS(PI8))$
  62. TS(TAN,PI4,1.0)$
  63. TS(COT,PI8,COS(pi8)/SIN(pi8))$
  64. TS(COT,PI4,1.0)$
  65. TS(SIND,30.0,0.5)$
  66. TS(ASIND,0.5,30.0)$
  67. TS(SQRT,2.0,Root2)$
  68. TS(SQRT,9.0,3.0)$
  69. TS(SQRT,100.0,10.0)$
  70. NaturalE:=2.718281828$
  71. TS(EXP,1.0,NaturalE)$
  72. TS(LOG,SQRT(NaturalE),0.5)$
  73. TS(LOG,NaturalE,1.0)$
  74. TS(LOG,NaturalE**2,2.0)$
  75. TS(LOG,1.0/NaturalE**2, -2.0)$
  76. TS(LOG2,Root2,0.5)$
  77. TS(LOG2,2.0,1.0)$
  78. TS(LOG2,4.0,2.0)$
  79. TS(LOG2,0.5, -1.0)$
  80. TS(LOG10,SQRT(10.0),0.5)$
  81. TS(LOG10,10.0,1.0)$
  82. TS(LOG10,100.0,2.0)$
  83. TS(LOG10, 1.0E30, 30.0)$
  84. TS(LOG10, 1.0E-30, -30.0)$
  85. End$