math.log 17 KB

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