math.log 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705
  1. Codemist Standard Lisp 3.54 for DEC Alpha: May 23 1994
  2. Dump file created: Mon May 23 10:39:11 1994
  3. REDUCE 3.5, 15-Oct-93 ...
  4. Memory allocation: 6023424 bytes
  5. +++ About to read file ndotest.red
  6. % Test of Math Package.
  7. % Author: Stanley L. Kameny <stan%valley.uucp@rand.org>.
  8. % Copyright (c) 1987, 1988, 1989, 1991 Stanley L. Kameny.
  9. % All Rights Reserved.
  10. %*********************************************************************
  11. %**
  12. %** This math package will compute the floating point values of **
  13. %** the usual elementary functions, namely: **
  14. %** sin asin sind asind sinh asinh **
  15. %** cos acos cosd acosd cosh acosh **
  16. %** tan atan tand atand tanh atanh **
  17. %** cot acot cotd acotd coth acoth **
  18. %** sec asec secd asecd sech asech **
  19. %** csc acsc cscd acscd csch acsch **
  20. %** atan2 atan2d **
  21. %** exp ln sqrt **
  22. %** expt log cbrt **
  23. %** logb hypot **
  24. %** log10 floor **
  25. %** ceiling **
  26. %** round **
  27. %** **
  28. %** All functions are computed to the accuracy of the floating- **
  29. %** point precision of the system set up at the time. **
  30. %** **
  31. %*********************************************************************
  32. %** File #1===Trig Function Tests===
  33. %** Trig functions are tested in both degrees and radians modes.
  34. %*********************************************************************
  35. symbolic;
  36. nil
  37. math!!label;
  38. "Math package mod 1.7, 1 May 93"
  39. symbolic procedure terpr(i,j); if remainder(i,j)=0 then terpri()$
  40. % #1: sind**2+cosd**2 test: ideal answers 1.0 for all args.
  41. for i:=0:45 do <<write " ",i,"->",sind float i**2+cosd float i**2;
  42. terpr(i,4)>>;
  43. 0->1.0
  44. 1->1.0 2->1.0 3->1.0 4->1.0
  45. 5->1.0 6->1.0 7->1.0 8->1.0
  46. 9->1.0 10->1.0 11->1.0 12->1.0
  47. 13->1.0 14->1.0 15->1.0 16->1.0
  48. 17->1.0 18->1.0 19->1.0 20->1.0
  49. 21->1.0 22->1.0 23->1.0 24->1.0
  50. 25->1.0 26->1.0 27->1.0 28->1.0
  51. 29->1.0 30->1.0 31->1.0 32->1.0
  52. 33->1.0 34->1.0 35->1.0 36->1.0
  53. 37->1.0 38->1.0 39->1.0 40->1.0
  54. 41->1.0 42->1.0 43->1.0 44->1.0
  55. 45->1.0
  56. nil
  57. % #2: quadrant test of sind, cosd: proper answers + +,+ -,- -,- +.
  58. begin scalar a;
  59. a:= sind 45.0;
  60. for i:= 0.0:3.0 do
  61. <<write " ",sind(i*90+45)/a," ", cosd (i*90+45)/a;terpri()>>
  62. end$
  63. 1.0 1.0
  64. 1.0 -1.0
  65. -1.0 -1.0
  66. -1.0 1.0
  67. % #3: scaling test: all values should be 1 exactly.
  68. begin scalar a; a:= cosd 60.0;
  69. % for i:= -10.0:10.0 do write fix(cosd(60+i*360)/a)," "
  70. for i:= -10.0:10.0 do write round(cosd(60+i*360)/a)," "
  71. end$
  72. 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
  73. % #4: test of radians -> degrees evaluation: ideal values 1.0.
  74. array a(6)$
  75. begin
  76. for i:=1:6 do a(i):=sind(15.0*i);
  77. for i:=1:6 do <<write sin(pii2*i/6.0)/a(i)," "; terpr(i,3)>>
  78. end$
  79. 1.0 1.0 1.0
  80. 1.0 1.0 1.0
  81. % #5: test of tand*cotd: ideal values 1.0.
  82. begin
  83. for i:=5 step 5 until 85 do
  84. <<write tand float i*cotd float i," "; terpr(i,25)>>;
  85. terpri()
  86. end$
  87. 1.0 1.0 1.0 1.0 1.0
  88. 1.0 1.0 1.0 1.0 1.0
  89. 1.0 1.0 1.0 1.0 1.0
  90. 1.0 1.0
  91. % #6: test of secd**2-tand**2: ideal values 1.0.
  92. begin
  93. for i:=5 step 5 until 85 do
  94. <<write secd float i**2-tand float i**2," "; terpr(i,25)>>
  95. end$
  96. 1.0 1.0 1.0 1.0 1.0
  97. 1.0 1.0 1.0 1.0 1.0
  98. 1.0 1.0 1.0 1.0 1.0
  99. 1.0 1.0
  100. % #7: test of cscd**2-cotd**2: ideal values 1.0.
  101. begin
  102. for i:=5 step 5 until 85 do
  103. <<write cscd float i**2-cotd float i**2," "; terpr(i,25)>>
  104. end$
  105. 1.0 1.0 1.0 1.0 1.0
  106. 1.0 1.0 1.0 1.0 1.0
  107. 1.0 1.0 1.0 1.0 1.0
  108. 1.0 1.0
  109. % #8: test of asind+acosd: ideal values 1.0.
  110. begin write "sind and cosd"; terpri();
  111. for i:=-10:10 do
  112. <<write (asind(0.1*i)+acosd(0.1*i))/90," "; terpr(i,5)>>;
  113. write "sin and cos";terpri();
  114. for i:=-10:10 do
  115. <<write (acos(0.1*i)+asin(0.1*i))/pii2," "; terpr(i,5)>>
  116. end$
  117. sind and cosd
  118. 1.0
  119. 1.0 1.0 1.0 1.0 1.0
  120. 1.0 1.0 1.0 1.0 1.0
  121. 1.0 1.0 1.0 1.0 1.0
  122. 1.0 1.0 1.0 1.0 1.0
  123. sin and cos
  124. 1.0
  125. 1.0 1.0 1.0 1.0 1.0
  126. 1.0 1.0 1.0 1.0 1.0
  127. 1.0 1.0 1.0 1.0 1.0
  128. 1.0 1.0 1.0 1.0 1.0
  129. % #9: test of atand+acotd: ideal values 1.0.
  130. begin scalar x; write "tand, atand and acotd"; terpri();
  131. for i:=-80 step 10 until 80 do
  132. <<x:=tand float i; write (atand x+acotd x)/90," "; terpr(i,50)>>;
  133. terpri();
  134. write "tan, atan and acot";terpri();
  135. for i:=-80 step 10 until 80 do
  136. <<x:= tan (pii2*i/90.0); write (atan x+acot x)/pii2," ";
  137. terpr(i,50)>>
  138. end$
  139. tand, atand and acotd
  140. 1.0 1.0 1.0 1.0
  141. 1.0 1.0 1.0 1.0 1.0
  142. 1.0 1.0 1.0 1.0 1.0
  143. 1.0 1.0 1.0
  144. tan, atan and acot
  145. 1.0 1.0 1.0 1.0
  146. 1.0 1.0 1.0 1.0 1.0
  147. 1.0 1.0 1.0 1.0 1.0
  148. 1.0 1.0 1.0
  149. % #10: test of atand tand: ideal values i for i:=-9:89.
  150. begin
  151. for i:=-9:89 do
  152. <<write " ",i,"->",if i=0 then 1.0 else atand tand float i;
  153. terpr(i,4)>>
  154. end$
  155. -9->-9.0 -8->-8.0
  156. -7->-7.0 -6->-6.0 -5->-5.0 -4->-4.0
  157. -3->-3.0 -2->-2.0 -1->-1.0 0->1.0
  158. 1->1.0 2->2.0 3->3.0 4->4.0
  159. 5->5.0 6->6.0 7->7.0 8->8.0
  160. 9->9.0 10->10.0 11->11.0 12->12.0
  161. 13->13.0 14->14.0 15->15.0 16->16.0
  162. 17->17.0 18->18.0 19->19.0 20->20.0
  163. 21->21.0 22->22.0 23->23.0 24->24.0
  164. 25->25.0 26->26.0 27->27.0 28->28.0
  165. 29->29.0 30->30.0 31->31.0 32->32.0
  166. 33->33.0 34->34.0 35->35.0 36->36.0
  167. 37->37.0 38->38.0 39->39.0 40->40.0
  168. 41->41.0 42->42.0 43->43.0 44->44.0
  169. 45->45.0 46->46.0 47->47.0 48->48.0
  170. 49->49.0 50->50.0 51->51.0 52->52.0
  171. 53->53.0 54->54.0 55->55.0 56->56.0
  172. 57->57.0 58->58.0 59->59.0 60->60.0
  173. 61->61.0 62->62.0 63->63.0 64->64.0
  174. 65->65.0 66->66.0 67->67.0 68->68.0
  175. 69->69.0 70->70.0 71->71.0 72->72.0
  176. 73->73.0 74->74.0 75->75.0 76->76.0
  177. 77->77.0 78->78.0 79->79.0 80->80.0
  178. 81->81.0 82->82.0 83->83.0 84->84.0
  179. 85->85.0 86->86.0 87->87.0 88->88.0
  180. 89->89.0
  181. % #11: test of acot cotd: ideal values 10*i for i:=1:17.
  182. begin
  183. for i:=10 step 10 until 170 do
  184. <<write " ",i,"->",acotd cotd i; terpr(i,40)>>; terpri();terpri() end$
  185. 10->10.0 20->20.0 30->30.0 40->40.0
  186. 50->50.0 60->60.0 70->70.0 80->80.0
  187. 90->90.0 100->100.0 110->110.0 120->120.0
  188. 130->130.0 140->140.0 150->150.0 160->160.0
  189. 170->170.0
  190. % #12: test of asind sind: ideal values 10*i for i:=-9:9.
  191. begin
  192. for i:=-90 step 10 until 90 do
  193. <<write " ",i,"->",asind sind float i; terpr(i,40)>>
  194. end$
  195. -90->-90.0 -80->-80.0
  196. -70->-70.0 -60->-60.0 -50->-50.0 -40->-40.0
  197. -30->-30.0 -20->-20.0 -10->-10.0 0->0.0
  198. 10->10.0 20->20.0 30->30.0 40->40.0
  199. 50->50.0 60->60.0 70->70.0 80->80.0
  200. 90->90.0
  201. % #13: test of acosd cosd: ideal values 10*i for i:=1:18.
  202. begin
  203. for i:=10 step 10 until 180 do
  204. <<write " ",i,"->",acosd cosd float i; terpr(i,40)>>
  205. end$
  206. 10->10.0 20->20.0 30->30.0 40->40.0
  207. 50->50.0 60->60.0 70->70.0 80->80.0
  208. 90->90.0 100->100.0 110->110.0 120->120.0
  209. 130->130.0 140->140.0 150->150.0 160->160.0
  210. 170->170.0 180->180.0
  211. % #14: test of acscd cscd: ideal values 10*i for i:=-9:9, except
  212. % error for i=0.
  213. begin
  214. for i:=-90 step 10 until 90 do
  215. <<write " ",i,"->",if i=0 then "error" else acscd cscd float i;
  216. terpr(i,40)>>
  217. end$
  218. -90->-90.0 -80->-80.0
  219. -70->-70.0 -60->-60.0 -50->-50.0 -40->-40.0
  220. -30->-30.0 -20->-20.0 -10->-10.0 0->error
  221. 10->10.0 20->20.0 30->30.0 40->40.0
  222. 50->50.0 60->60.0 70->70.0 80->80.0
  223. 90->90.0
  224. % #15: test of asecd secd: ideal values 10*i for i :=0:18. except
  225. % error for i=9.
  226. begin
  227. for i:=0 step 10 until 180 do
  228. <<write" ",i,"->",if i=90 then "error" else asecd secd float i;
  229. terpr(i,40)>>
  230. end$
  231. 0->0.0
  232. 10->10.0 20->20.0 30->30.0 40->40.0
  233. 50->50.0 60->60.0 70->70.0 80->80.0
  234. 90->error 100->100.0 110->110.0 120->120.0
  235. 130->130.0 140->140.0 150->150.0 160->160.0
  236. 170->170.0 180->180.0
  237. %*********************************************************************
  238. %** ===Exp,Log,Sqrt,Cbrt, and Expt Function tests===
  239. %*********************************************************************
  240. % #16: test of properties of exp function: ideal results 1.0.
  241. array b(5)$
  242. begin scalar x; x:=0;
  243. write "multiplicative property";terpri();
  244. for i:=0:5 do b(i):=1+i/6.0; for i:=0:5 do for j:=i:5 do
  245. <<write " ",exp (b(i)+b(j))/exp(b(i))/exp(b(j));
  246. terpr(x:=x+1,5)>>
  247. end$
  248. multiplicative property
  249. 1.0 1.0 1.0 1.0 1.0
  250. 1.0 1.0 1.0 1.0 1.0
  251. 1.0 1.0 1.0 1.0 1.0
  252. 1.0 1.0 1.0 1.0 1.0
  253. 1.0
  254. % #17: various properties of exp: ideal results 1.0.
  255. begin write "inverse property"$ terpri()$
  256. for i:=1:5 do write " ",exp(b(i))*exp(-b(i));terpri();
  257. write "squares"; terpri();
  258. for i:=-10:10 do
  259. <<write " ",sqrt(exp(0.2*i))/exp(0.1*i); terpr(i,5)>>;
  260. write "cubes"; terpri();
  261. for i:=-10:10 do
  262. <<write " ",cbrt(exp(0.3*i))/exp(0.1*i); terpr(i,5)>>
  263. end$
  264. inverse property
  265. 1.0 1.0 1.0 1.0 1.0
  266. squares
  267. 1.0
  268. 1.0 1.0 1.0 1.0 1.0
  269. 1.0 1.0 1.0 1.0 1.0
  270. 1.0 1.0 1.0 1.0 1.0
  271. 1.0 1.0 1.0 1.0 1.0
  272. cubes
  273. 1.0
  274. 1.0 1.0 1.0 1.0 1.0
  275. 1.0 1.0 1.0 1.0 1.0
  276. 1.0 1.0 1.0 1.0 1.0
  277. 1.0 1.0 1.0 1.0 1.0
  278. % #18: test of log exp: ideal results 1.0.
  279. begin for i:=-5:5 do
  280. <<write if i=0 then "0/0" else (log exp float i)/i," "; terpr(i,5)>>
  281. end$
  282. 1.0
  283. 1.0 1.0 1.0 1.0 0/0
  284. 1.0 1.0 1.0 1.0 1.0
  285. % #19: test of log10 expt(10.0,i): ideal results 1.0.
  286. begin scalar i; write "small values i:=-5:5"; terpri();
  287. for j:=-5:5 do
  288. <<write if j neq 0 then log10 float expt(10.0,j)/j
  289. else "zero"," ";
  290. terpr(j,5)>>;
  291. write "large i=2**j where j:=0:6"; terpri();
  292. for j:=0:5 do
  293. <<write (log10 float expt(10.0,2**j))/2**j," "; terpr(j,5)>>;
  294. terpri();
  295. write "noninteger values of i=j/10.0 where j:=1:20";terpri();
  296. for j:=1:20 do
  297. <<i:=j/10.0; write (log10 float expt(10,i))/i," ";
  298. terpr(j,5)>>
  299. end$
  300. small values i:=-5:5
  301. 1.0
  302. 1.0 1.0 1.0 1.0 zero
  303. 1.0 1.0 1.0 1.0 1.0
  304. large i=2**j where j:=0:6
  305. 1.0
  306. 1.0 1.0 1.0 1.0 1.0
  307. noninteger values of i=j/10.0 where j:=1:20
  308. 1.0 1.0 1.0 1.0 1.0
  309. 1.0 1.0 1.0 1.0 1.0
  310. 1.0 1.0 1.0 1.0 1.0
  311. 1.0 1.0 1.0 1.0 1.0
  312. % #20: test of properties of expt(x,i)*(expt(x,-i). ideal result 1.0.
  313. begin integer j;
  314. for x:=2:6 do for i:=2:6 do
  315. <<write expt(float x,i)*expt(float x,-i)," "; terpr(j:=j+1,5)>>
  316. end$
  317. 1.0 1.0 1.0 1.0 1.0
  318. 1.0 1.0 1.0 1.0 1.0
  319. 1.0 1.0 1.0 1.0 1.0
  320. 1.0 1.0 1.0 1.0 1.0
  321. 1.0 1.0 1.0 1.0 1.0
  322. % #21: test of expt(-x,i)/expt(x,i) for fractional i.
  323. begin integer j,k; write "odd numerator. ideal result -1.0"; terpri();
  324. for i:=1:10 do
  325. <<k:=(2*i-1.0)/(8*i+1); write rexpt(-8,k)/rexpt(8,k)," ";
  326. terpr(j:=j+1,5)>>;
  327. write "even numerator. ideal result 1.0"; terpri();
  328. for i:=1:10 do
  329. <<k:=(2.0*i)/(8*i+1); write rexpt(-8,k)/rexpt(8,k)," ";
  330. terpr(j:=j+1,5)>>
  331. end$
  332. odd numerator. ideal result -1.0
  333. -1.0 -1.0 -1.0 -1.0 -1.0
  334. -1.0 -1.0 -1.0 -1.0 -1.0
  335. even numerator. ideal result 1.0
  336. 1.0 1.0 1.0 1.0 1.0
  337. 1.0 1.0 1.0 1.0 1.0
  338. % #22: test of properties of ln or log or logb:
  339. % inverse argument: ideal result -1.0.
  340. begin integer x;
  341. for i:=2:5 do for j:= 2:10 do
  342. <<x:=x+1; write logb(float i,float j)/logb(float i,1.0/j)," ";
  343. terpr(x,5)>>
  344. end$
  345. -1.0 -1.0 -1.0 -1.0 -1.0
  346. -1.0 -1.0 -1.0 -1.0 -1.0
  347. -1.0 -1.0 -1.0 -1.0 -1.0
  348. -1.0 -1.0 -1.0 -1.0 -1.0
  349. -1.0 -1.0 -1.0 -1.0 -1.0
  350. -1.0 -1.0 -1.0 -1.0 -1.0
  351. -1.0 -1.0 -1.0 -1.0 -1.0
  352. -1.0
  353. % #23: test of log(a*b) = log a+log b: ideal result 1.0.
  354. begin integer x;
  355. for i:=1:5 do for j:=i:5 do
  356. <<write log (i*j*0.01)/(log (i*0.1)+log(j*0.1))," ";
  357. terpr(x:=x+1,5)>>
  358. end$
  359. 1.0 1.0 1.0 1.0 1.0
  360. 1.0 1.0 1.0 1.0 1.0
  361. 1.0 1.0 1.0 1.0 1.0
  362. % #24:test of sqrt x*sqrt x/x for x:=5i*(5i/3)**i where i:=1:20
  363. % (test values strictly arbitrary): ideal results 1.0.
  364. begin scalar x,s;
  365. for i:=1:20 do
  366. <<x:= 5.0*i;s:=sqrt(x:=x*(expt(x/3,i))); write s*s/x," ";
  367. terpr(i,5)>>
  368. end$
  369. 1.0 1.0 1.0 1.0 1.0
  370. 1.0 1.0 1.0 1.0 1.0
  371. 1.0 1.0 1.0 1.0 1.0
  372. 1.0 1.0 1.0 1.0 1.0
  373. % #25: test of cbrt x**3/x for x:=5i*(5i/3)**i where i:=-9:10
  374. % (test values strictly arbitrary):ideal results 1.0.
  375. begin scalar x,s;
  376. for i:=-9:10 do
  377. <<x:= 5.0*i; if i neq 0 then s:= cbrt(x:=x*(expt(x/3,i)));
  378. write if i=0 then 1 else s*s*s/x," "; terpr(i,5)>>
  379. end$
  380. 1.0 1.0 1.0 1.0 1.0
  381. 1.0 1.0 1.0 1.0 1
  382. 1.0 1.0 1.0 1.0 1.0
  383. 1.0 1.0 1.0 1.0 1.0
  384. %*********************************************************************
  385. %** ===Hyperbolic Function Tests===
  386. %*********************************************************************
  387. % #26: test of sinh x+ cosh x= exp x: ideal results 1.0.
  388. begin scalar x;
  389. for i:=1:10 do
  390. <<x:=ln float i$ write (sinh x+cosh x)/exp x," "$ terpr(i,5)>>
  391. end$
  392. 1.0 1.0 1.0 1.0 1.0
  393. 1.0 1.0 1.0 1.0 1.0
  394. % #27: test of cosh x-sinh x= exp(-x): ideal results 1.0.
  395. begin scalar x;
  396. for i:=1:10 do
  397. <<x:=ln float i$ write(cosh x-sinh x)*exp x," "$ terpr(i,5)>>
  398. end$
  399. 1.0 1.0 1.0 1.0 1.0
  400. 1.0 1.0 1.0 1.0 1.0
  401. % #28: test of (cosh x)**2-(sinh x)**2: ideal results 1.0.
  402. begin scalar x$
  403. for i:=1:10 do
  404. <<x:=ln float i$write(cosh x)**2-(sinh x)**2," "; terpr(i,5)>>
  405. end$
  406. 1.0 1.0 1.0 1.0 1.0
  407. 1.0 1.0 1.0 1.0 1.0
  408. % #29: test of tanh*cosh/sinh: ideal results 1.0.
  409. begin scalar x;
  410. for i:=1:20 do
  411. <<x:=ln(i*0.1);
  412. write if i=10 then 1 else tanh x*cosh x/sinh x," ";
  413. terpr(i,5)>>
  414. end$
  415. 1.0 1.0 1.0 1.0 1.0
  416. 1.0 1.0 1.0 1.0 1
  417. 1.0 1.0 1.0 1.0 1.0
  418. 1.0 1.0 1.0 1.0 1.0
  419. % #30: test of tanh*coth: ideal results 1.0.
  420. begin scalar x;
  421. for i:=1:20 do
  422. <<x:=ln(i*0.1); write if i=10 then 1 else tanh x*coth x," ";
  423. terpr(i,5)>>
  424. end$
  425. 1.0 1.0 1.0 1.0 1.0
  426. 1.0 1.0 1.0 1.0 1
  427. 1.0 1.0 1.0 1.0 1.0
  428. 1.0 1.0 1.0 1.0 1.0
  429. % #31: test of sech*cosh: ideal results 1.0.
  430. begin scalar x;
  431. for i:=1:20 do
  432. <<x:=ln(i*0.1); write sech x*cosh x," "; terpr(i,5)>>
  433. end$
  434. 1.0 1.0 1.0 1.0 1.0
  435. 1.0 1.0 1.0 1.0 1.0
  436. 1.0 1.0 1.0 1.0 1.0
  437. 1.0 1.0 1.0 1.0 1.0
  438. % #32: test of csch*sinh: ideal results 1.0.
  439. begin scalar x;
  440. for i:=1:20 do
  441. <<x:=ln(i*0.1); write if i=10 then 1 else csch x*sinh x," ";
  442. terpr(i,5)>>
  443. end$
  444. 1.0 1.0 1.0 1.0 1.0
  445. 1.0 1.0 1.0 1.0 1
  446. 1.0 1.0 1.0 1.0 1.0
  447. 1.0 1.0 1.0 1.0 1.0
  448. % #33: test of asinh sinh: ideal results 1.0.
  449. begin scalar x; for i:=1:20 do
  450. <<x:=ln(i*0.1); write if i=10 then 1 else asinh sinh x/x," ";
  451. terpr(i,5)>>
  452. end$
  453. 1.0 1.0 1.0 1.0 1.0
  454. 1.0 1.0 1.0 1.0 1
  455. 1.0 1.0 1.0 1.0 1.0
  456. 1.0 1.0 1.0 1.0 1.0
  457. % #34: test of acosh cosh: ideal results 1.0. However, acosh x
  458. % loses accuracy as x -> 1 since d/dx cosh x -> 0.
  459. begin scalar x;
  460. for i:=1:20 do
  461. <<x:=ln(1+i*0.05); write acosh cosh x/x," "; terpr(i,5)>>
  462. end$
  463. 1.0 1.0 0.99999999999999 1.0 1.0
  464. 1.0 1.0 1.0 1.0 1.0
  465. 1.0 1.0 1.0 1.0 1.0
  466. 1.0 1.0 1.0 1.0 1.0
  467. % #35: test of cosh acosh:ideal results 1.0.
  468. begin scalar x;
  469. for i:=1:50 do
  470. <<x:=1+i/25.0; write (cosh acosh x)/x," "; terpr(i,5)>>
  471. end$
  472. 1.0 1.0 1.0 1.0 1.0
  473. 1.0 1.0 1.0 1.0 1.0
  474. 1.0 1.0 1.0 1.0 1.0
  475. 1.0 1.0 1.0 1.0 1.0
  476. 1.0 1.0 1.0 1.0 1.0
  477. 1.0 1.0 1.0 1.0 1.0
  478. 1.0 1.0 1.0 1.0 1.0
  479. 1.0 1.0 1.0 1.0 1.0
  480. 1.0 1.0 1.0 1.0 1.0
  481. 1.0 1.0 1.0 1.0 1.0
  482. % #36: test of atanh tanh: ideal results 1.0.
  483. begin scalar x;
  484. for i:=1:20 do
  485. <<x:=ln(i*0.1); write if i=10 then 1 else (atanh tanh x)/x," ";
  486. terpr(i,5)>>
  487. end$
  488. 1.0 1.0 1.0 1.0 1.0
  489. 1.0 1.0 1.0 1.0 1
  490. 1.0 1.0 1.0 1.0 1.0
  491. 1.0 1.0 1.0 1.0 1.0
  492. % #37: test of acoth coth: ideal results 1.0.
  493. begin scalar x;
  494. for i:=1:20 do
  495. <<x:=ln(i*0.1); write if i=10 then 1 else (acoth coth x)/x," ";
  496. terpr(i,5)>>
  497. end$
  498. 1.0 1.0 1.0 1.0 1.0
  499. 1.0 1.0 1.0 1.0 1
  500. 1.0 1.0 1.0 1.0 1.0
  501. 1.0 1.0 1.0 1.0 1.0
  502. % #38: test of asech sech: ideal results 1.0. However, asech x
  503. % loses accuracy as x -> 1 since d/dx sech x -> 0.
  504. begin scalar x;
  505. for i:=1:20 do
  506. <<x:=ln(1+i*0.05); write (asech sech x)/x," "; terpr(i,5)>>
  507. end$
  508. 1.0 1.0 0.99999999999999 1.0 1.0
  509. 1.0 1.0 1.0 1.0 1.0
  510. 1.0 1.0 1.0 1.0 1.0
  511. 1.0 1.0 1.0 1.0 1.0
  512. % #39: test of acsch csch: ideal results 1.0.
  513. begin scalar x;
  514. for i:=1:20 do
  515. <<x:=ln(i*0.1); write if i=10 then 1 else (acsch csch x)/x," ";
  516. terpr(i,5)>>
  517. end$
  518. 1.0 1.0 1.0 1.0 1.0
  519. 1.0 1.0 1.0 1.0 1
  520. 1.0 1.0 1.0 1.0 1.0
  521. 1.0 1.0 1.0 1.0 1.0
  522. % End of Test.
  523. end;
  524. (TIME: math 1033 1033)
  525. nil
  526. End of Lisp run after 1.06+0.63 seconds